Reorganized everything into new structure
[webos-internals:adamrmcd-modifications.git] / messaging / messaging-enable-forwarding.patch
1 Index: /usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
2 ===================================================================
3 --- .orig/usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
4 +++ /usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js
5 @@ -1541,59 +1541,104 @@ var ChatviewAssistant = Class.create({
6                 MessagingMojoService.deleteMessage(this.controller, event.item.messageId);
7         },
8  
9 -       handleMessageTap: function(event){
10 -               var eventTarget = this.controller.get(event.originalEvent.target);
11 -                       
12 -               var mmsImageTarget = MessagingUtils.getClassUpChain(eventTarget,'MMSImageObject');
13 -               if(mmsImageTarget) {
14 -                       this.controller.stageController.pushScene('imageview', mmsImageTarget.getAttribute('originalSrc'));
15 -                       return;         
16 -               }
17 +        handleMessageTap: function(event){
18 +                var eventTarget = this.controller.get(event.originalEvent.target);
19  
20 -               var mmsVideoTarget = MessagingUtils.getClassUpChain(eventTarget,'mms-video');
21 -               if(mmsVideoTarget) {
22 -                       var videoPath = mmsVideoTarget.getAttribute('filePath');
23 -                       var videoName = mmsVideoTarget.getAttribute('fileInfo');
24 -                       
25 -                       var args = {
26 -                               appId: "com.palm.app.videoplayer",
27 -                               name: "nowplaying"
28 -                       };
29 -                       var params = {
30 -                               target: videoPath,
31 -                               title: videoName
32 -                       };
33 -                       this.controller.stageController.pushScene(args, params);                        
34 -                       return;         
35 -               }
36 -               
37 -               var mmsVcardTarget = MessagingUtils.getClassUpChain(eventTarget,'mms-vcard');
38 -               if(mmsVcardTarget) {
39 -                       var filePath = mmsVcardTarget.getAttribute('filePath');
40 -                       MessagingMojoService.launchFile(this.controller, 'text/x-vcard', 'file://'+filePath);
41 -                       return;         
42 -               }
43 -               
44 -               var mmsVcalTarget = MessagingUtils.getClassUpChain(eventTarget,'mms-vcal');
45 -               if(mmsVcalTarget) {
46 -                       var filePath = mmsVcalTarget.getAttribute('filePath');
47 -                       MessagingMojoService.launchFile(this.controller, 'text/x-vcalendar', 'file://'+filePath);
48 -                       return;         
49 -               }               
50 -                               
51 -               MessagingUtils.simpleListClick(this.controller.get(event.originalEvent.target), "chatRow", function(targetRow){
52 -                       var messageData = {
53 -                               errorCode: targetRow.getAttribute("errorCode"),
54 -                               status: targetRow.getAttribute("status"),
55 -                               messageId: targetRow.getAttribute("messageId"),
56 -                               flags: targetRow.getAttribute("flags"),
57 -                               messageType: targetRow.getAttribute("messageType")
58 -                       };
59 -                       
60 -                       MessagingMojoService.getMessageErrorInfo(this.controller, messageData.messageId, messageData.flags, this.handleMessageErrorPopup.bind(this,messageData));
61 +                var mmsImageTarget = MessagingUtils.getClassUpChain(eventTarget,'MMSImageObject');
62 +                if(mmsImageTarget) {
63 +                        var imagePath = mmsImageTarget.getAttribute('originalSrc');
64 +                        this.controller.showAlertDialog({
65 +                                onChoose: function(value) {if(value == "forward"){MessagingMojoService.forwardMessage(this.controller, event.item.messageText, imagePath);} else {this.controller.stageController.pushScene('imageview', imagePath);}},
66 +                                title: $L("Forward Message"),
67 +                                message: $L("Do you want to forward this message?"),
68 +                                choices:[
69 +                                        {label:$L("Yes"), value:"forward", type:"affirmative"},
70 +                                        {label:$L("No"), value:"", type:"negative"}
71 +                                ]
72 +                        });
73 +                        return;
74 +                }
75  
76 -               }.bind(this), false);
77 -       },
78 +                var mmsVideoTarget = MessagingUtils.getClassUpChain(eventTarget,'mms-video');
79 +                if(mmsVideoTarget) {
80 +                        var videoPath = mmsVideoTarget.getAttribute('filePath');
81 +                        var videoName = mmsVideoTarget.getAttribute('fileInfo');
82 +
83 +                        var args = {
84 +                                appId: "com.palm.app.videoplayer",
85 +                                name: "nowplaying"
86 +                        };
87 +                        var params = {
88 +                                target: videoPath,
89 +                                title: videoName
90 +                        };
91 +                        this.controller.showAlertDialog({
92 +                                onChoose: function(value) {if(value == "forward"){MessagingMojoService.forwardMessage(this.controller, event.item.messageText, videoPath);} else {this.controller.stageController.pushScene(args, params);}},
93 +                                title: $L("Forward Message"),
94 +                                message: $L("Do you want to forward this message?"),
95 +                                choices:[
96 +                                        {label:$L("Yes"), value:"forward", type:"affirmative"},
97 +                                        {label:$L("No"), value:"", type:"negative"}
98 +                                ]
99 +                        });
100 +                        return;
101 +                }
102 +
103 +                var mmsVcardTarget = MessagingUtils.getClassUpChain(eventTarget,'mms-vcard');
104 +                if(mmsVcardTarget) {
105 +                        var filePath = mmsVcardTarget.getAttribute('filePath');
106 +                        this.controller.showAlertDialog({
107 +                                onChoose: function(value) {if(value == "forward"){MessagingMojoService.forwardMessage(this.controller, event.item.messageText, filePath);} else {this.controller.stageController.pushScene('mmsTextAttachment', filePath);}},
108 +                                title: $L("Forward Message"),
109 +                                message: $L("Do you want to forward this message?"),
110 +                                choices:[
111 +                                        {label:$L("Yes"), value:"forward", type:"affirmative"},
112 +                                        {label:$L("No"), value:"", type:"negative"}
113 +                                ]
114 +                        });
115 +                        return;
116 +                }
117 +
118 +                var mmsVcalTarget = MessagingUtils.getClassUpChain(eventTarget,'mms-vcal');
119 +                if(mmsVcalTarget) {
120 +                        var filePath = mmsVcalTarget.getAttribute('filePath');
121 +                        this.controller.showAlertDialog({
122 +                                onChoose: function(value) {if(value == "forward"){MessagingMojoService.forwardMessage(this.controller, event.item.messageText, filePath);} else {this.controller.stageController.pushScene('mmsTextAttachment', filePath);}},
123 +                                title: $L("Forward Message"),
124 +                                message: $L("Do you want to forward this message?"),
125 +                                choices:[
126 +                                        {label:$L("Yes"), value:"forward", type:"affirmative"},
127 +                                        {label:$L("No"), value:"", type:"negative"}
128 +                                ]
129 +                        });
130 +                        return;
131 +                }
132 +
133 +                if (!mmsImageTarget && !mmsVideoTarget && !mmsVcardTarget && !mmsVcalTarget) {
134 +                        this.controller.showAlertDialog({
135 +                                onChoose: function(value) {if(value == "forward"){MessagingMojoService.forwardMessage(this.controller, event.item.messageText, '');}},
136 +                                title: $L("Forward Message"),
137 +                                message: $L("Do you want to forward this message?"),
138 +                                choices:[
139 +                                        {label:$L("Yes"), value:"forward", type:"affirmative"},
140 +                                        {label:$L("No"), value:"", type:"negative"}
141 +                                ]
142 +                        });
143 +                }
144 +
145 +                MessagingUtils.simpleListClick(this.controller.get(event.originalEvent.target), "chatRow", function(targetRow){
146 +                        var messageData = {
147 +                                errorCode: targetRow.getAttribute("errorCode"),
148 +                                status: targetRow.getAttribute("status"),
149 +                                messageId: targetRow.getAttribute("messageId"),
150 +                                flags: targetRow.getAttribute("flags"),
151 +                                messageType: targetRow.getAttribute("messageType")
152 +                        };
153 +
154 +                        MessagingMojoService.getMessageErrorInfo(this.controller, messageData.messageId, messageData.flags, this.handleMessageErrorPopup.bind(this,messageData));
155 +
156 +                }.bind(this), false);
157 +        },
158         
159         
160         handleMessageErrorPopup: function(messageData,messageErrorData) {
161 Index: /usr/palm/applications/com.palm.app.messaging/app/models/messaging-luna-service.js
162 ===================================================================
163 --- .orig/usr/palm/applications/com.palm.app.messaging/app/models/messaging-luna-service.js
164 +++ /usr/palm/applications/com.palm.app.messaging/app/models/messaging-luna-service.js
165 @@ -8,7 +8,25 @@ var MessagingMojoService = {
166    displayIdentifier: 'palm://com.palm.display/control',
167    telephonyIdentifier: 'palm://com.palm.telephony',
168    systemManagerIdentifier: 'palm://com.palm.systemmanager',
169 +  forwardIdentifier: 'palm://com.palm.applicationManager',
170  
171 +  forwardMessage: function(sceneController,messageText,attachment) {
172 +       var opts = {
173 +                method: 'launch',
174 +                parameters: {
175 +                        id: 'com.palm.app.messaging',
176 +                        params: {
177 +                        }
178 +                }
179 +        };
180 +        if (messageText)
181 +                opts.parameters.params.messageText = 'FWD: '+messageText;
182 +        if (attachment)
183 +                opts.parameters.params.attachment = attachment;
184 +        return sceneController.serviceRequest(MessagingMojoService.forwardIdentifier,opts);
185 +  },
186 +  
187 +  
188    launchMessaging: function(sceneController,params) {  
189         return sceneController.serviceRequest("palm://com.palm.applicationManager", {
190                 method:'launch',