Difference between revisions of "Patch Messaging Forward Messages"

From WebOS Internals
Jump to navigation Jump to search
(New page: '''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 beha...)
 
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
'''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 will still prompt for a save, etc.
+
{{template:patch}}
 +
'''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.
  
'''Update:''' There is a patch available for the mod.  Please see [[[applying-patches]]] for instructions.
+
'''Note:''' There is a patch available for the mod.  Please see [[Applying Patches]] for instructions.
  
 
==Step One: Create the model==
 
==Step One: Create the model==
Line 7: Line 8:
 
Back up and modify /usr/palm/applications/com.palm.app.messaging/app/models/messaging-luna-service.js.
 
Back up and modify /usr/palm/applications/com.palm.app.messaging/app/models/messaging-luna-service.js.
  
After line 7, add the following:
+
After line 10, add the following:
 
<pre><nowiki>
 
<pre><nowiki>
 
forwardIdentifier: 'palm://com.palm.applicationManager',
 
forwardIdentifier: 'palm://com.palm.applicationManager',
  
   forwardMessage: function(sceneController,messageText) {
+
   forwardMessage: function(sceneController,messageText,attachment) {
return sceneController.serviceRequest(MessagingMojoService.forwardIdentifier,{
+
var opts = {
method: 'launch',
+
                method: 'launch',
parameters: {
+
                parameters: {
id: 'com.palm.app.messaging',
+
                        id: 'com.palm.app.messaging',
params: {
+
                        params: {
messageText: 'FWD: '+messageText
+
                        }
}
+
                }
}
+
        };
});
+
        if (messageText)
 +
                opts.parameters.params.messageText = 'FWD: '+messageText;
 +
        if (attachment)
 +
                opts.parameters.params.attachment = attachment;
 +
        return sceneController.serviceRequest(MessagingMojoService.forwardIdentifier,opts);
 
   },
 
   },
  
Line 29: Line 34:
 
Back up and modify /usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
 
Back up and modify /usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
  
Find this block of code, starting at or near line 1440:
+
Find the function '''handleMessageTap''', starting on line 1480:
 +
 
 +
The first few lines:
 +
<pre><nowiki>
 +
        handleMessageTap: function(event){ 
 +
                var eventTarget = this.controller.get(event.originalEvent.target);
 +
 
 +
                var mmsImageTarget = MessagingUtils.getClassUpChain(eventTarget,'MMSImageObject');                                                                               
 +
                if(mmsImageTarget) {
 +
</nowiki></pre>
 +
 
 +
And the last few lines:
 +
<pre><nowiki>
 +
                                                                                                                                                                                 
 +
                        MessagingMojoService.getMessageErrorInfo(this.controller, messageData.messageId, messageData.flags, this.handleMessageErrorPopup.bind(this,messageData)); 
 +
                                                                                                                                                                                 
 +
                }.bind(this), false);                                                                                                                                             
 +
        },
 +
</nowiki></pre>
 +
 
 +
 
 +
Replace the entire function with the following:
 
<pre><nowiki>
 
<pre><nowiki>
 +
        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');
 
                 var mmsVcalTarget = MessagingUtils.getClassUpChain(eventTarget,'mms-vcal');
 
                 if(mmsVcalTarget) {
 
                 if(mmsVcalTarget) {
 
                         var filePath = mmsVcalTarget.getAttribute('filePath');
 
                         var filePath = mmsVcalTarget.getAttribute('filePath');
                         this.controller.stageController.pushScene('mmsTextAttachment', 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;
 
                         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);
 +
        },
 
</nowiki></pre>
 
</nowiki></pre>
Immediately below that block, add the following:
 
<pre><nowiki>
 
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"}
 
]
 
});
 
}
 
</nowiki></pre>
 
-showAlertDialog by Atlanta
 
  
Reboot for the changes to take effect.   
+
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
  
== Usage==
+
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
To forward a message, open the Messaging application, tap a chat thread, then tap an individual message.  If the message has an attachment, make sure you tap on the text of the message.  A new compose card will open with the message text pre-populated.  Simply choose the recipient(s).
 
  
 
= Credits=
 
= Credits=
Submitted by JackieRipper
+
Submitted by JackieRipper and Atlanta

Latest revision as of 11:14, 8 September 2009


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