Patch Messaging Forward Messages

Description: This mod will allow you to forward a message by simply tapping on the text of a message in the chat view. It does not interfere with the current attachment-tapping behavior. Tapping an attached image ask if you want to forward. Selecting "No" will still prompt for a save, etc., while selecting "Yes" will open a the compose dialog, with the message and attachments pre-populated.

Note: There is a patch available for the mod. Please see Applying Patches for instructions.

Step One: Create the model
Back up and modify /usr/palm/applications/com.palm.app.messaging/app/models/messaging-luna-service.js.

After line 10, add the following: forwardIdentifier: 'palm://com.palm.applicationManager',

forwardMessage: function(sceneController,messageText,attachment) { var opts = { method: 'launch', parameters: { id: 'com.palm.app.messaging', params: { }               }        };        if (messageText) opts.parameters.params.messageText = 'FWD: '+messageText; if (attachment) opts.parameters.params.attachment = attachment; return sceneController.serviceRequest(MessagingMojoService.forwardIdentifier,opts); },

Step Two: Make it respond to a tap on the text
Back up and modify /usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js

Find the function handleMessageTap, starting on line 1480:

The first few lines: handleMessageTap: function(event){ var eventTarget = this.controller.get(event.originalEvent.target);

var mmsImageTarget = MessagingUtils.getClassUpChain(eventTarget,'MMSImageObject'); if(mmsImageTarget) {

And the last few lines: MessagingMojoService.getMessageErrorInfo(this.controller, messageData.messageId, messageData.flags, this.handleMessageErrorPopup.bind(this,messageData)); }.bind(this), false);                                                                                                                                                     },

Replace the entire function with the following: handleMessageTap: function(event){ var eventTarget = this.controller.get(event.originalEvent.target);

var mmsImageTarget = MessagingUtils.getClassUpChain(eventTarget,'MMSImageObject'); if(mmsImageTarget) { var imagePath = mmsImageTarget.getAttribute('originalSrc'); this.controller.showAlertDialog({                               onChoose: function(value) {if(value == "forward"){MessagingMojoService.forwardMessage(this.controller, event.item.messageText, imagePath);} else {this.controller.stageController.pushScene('imageview', imagePath);}},                                title: $L("Forward Message"),                                message: $L("Do you want to forward this message?"),                                choices:[                                        {label:$L("Yes"), value:"forward", type:"affirmative"},                                        {label:$L("No"), value:"", type:"negative"}                                ]                        }); return; }

var mmsVideoTarget = MessagingUtils.getClassUpChain(eventTarget,'mms-video'); if(mmsVideoTarget) { var videoPath = mmsVideoTarget.getAttribute('filePath'); var videoName = mmsVideoTarget.getAttribute('fileInfo');

var args = { appId: "com.palm.app.videoplayer", name: "nowplaying" };                       var params = { target: videoPath, title: videoName };                       this.controller.showAlertDialog({                                onChoose: function(value) {if(value == "forward"){MessagingMojoService.forwardMessage(this.controller, event.item.messageText, videoPath);} else {this.controller.stageController.pushScene(args, params);}},                                title: $L("Forward Message"),                                message: $L("Do you want to forward this message?"),                                choices:[                                        {label:$L("Yes"), value:"forward", type:"affirmative"},                                        {label:$L("No"), value:"", type:"negative"}                                ]                        }); return; }

var mmsVcardTarget = MessagingUtils.getClassUpChain(eventTarget,'mms-vcard'); if(mmsVcardTarget) { var filePath = mmsVcardTarget.getAttribute('filePath'); this.controller.showAlertDialog({                               onChoose: function(value) {if(value == "forward"){MessagingMojoService.forwardMessage(this.controller, event.item.messageText, filePath);} else {this.controller.stageController.pushScene('mmsTextAttachment', filePath);}},                                title: $L("Forward Message"),                                message: $L("Do you want to forward this message?"),                                choices:[                                        {label:$L("Yes"), value:"forward", type:"affirmative"},                                        {label:$L("No"), value:"", type:"negative"}                                ]                        }); return; }

var mmsVcalTarget = MessagingUtils.getClassUpChain(eventTarget,'mms-vcal'); if(mmsVcalTarget) { var filePath = mmsVcalTarget.getAttribute('filePath'); this.controller.showAlertDialog({                               onChoose: function(value) {if(value == "forward"){MessagingMojoService.forwardMessage(this.controller, event.item.messageText, filePath);} else {this.controller.stageController.pushScene('mmsTextAttachment', filePath);}},                                title: $L("Forward Message"),                                message: $L("Do you want to forward this message?"),                                choices:[                                        {label:$L("Yes"), value:"forward", type:"affirmative"},                                        {label:$L("No"), value:"", type:"negative"}                                ]                        }); return; }

if (!mmsImageTarget && !mmsVideoTarget && !mmsVcardTarget && !mmsVcalTarget) { this.controller.showAlertDialog({                               onChoose: function(value) {if(value == "forward"){MessagingMojoService.forwardMessage(this.controller, event.item.messageText, '');}},                                title: $L("Forward Message"),                                message: $L("Do you want to forward this message?"),                                choices:[                                        {label:$L("Yes"), value:"forward", type:"affirmative"},                                        {label:$L("No"), value:"", type:"negative"}                                ]                        }); }

MessagingUtils.simpleListClick(this.controller.get(event.originalEvent.target), "chatRow", function(targetRow){                       var messageData = {                                errorCode: targetRow.getAttribute("errorCode"),                                status: targetRow.getAttribute("status"),                                messageId: targetRow.getAttribute("messageId"),                                flags: targetRow.getAttribute("flags"),                                messageType: targetRow.getAttribute("messageType")                        };

MessagingMojoService.getMessageErrorInfo(this.controller, messageData.messageId, messageData.flags, this.handleMessageErrorPopup.bind(this,messageData));

}.bind(this), false);       },

Reboot for changes to take effect.

Usage
To forward a message, open the Messaging application, tap a chat thread, then tap an individual message. A dialog will pop up asking if you would like to forward. If the message has an attachment, it will be forwarded, as well. A new compose card will open with the message text pre-populated. Simply choose the recipient(s).

= Notes = Patching Patch Messaging Character Counter will not allow for this patch to work, please take a look into this. -thatdude

If the Patch Messaging Character Counter patch is applied manually it works fine with this patch. -NetWhiz

Would it be possible to make this into a patch that could be installed with preware? I think this would be much appreciated by people less inclined to root their pre. -The818Studios

= Credits= Submitted by JackieRipper and Atlanta