Commit 114123fc2e260a5e795bc6abf7ca968e769f3db6
- Diff rendering mode:
- inline
- side by side
messaging/contact-multitone.patch
(144 / 148)
|   | |||
| 21 | 21 | Mojo.Log.info("[CV] ****** chatview considerForNotification --- screen is on!"); | |
| 22 | 22 | if(data.notificationType == this.Messaging.notificationTypes.newMessage) { | |
| 23 | 23 | - data = {playSoundOnly:true}; | |
| 24 | + data = $H(data); | ||
| 25 | + data = data.merge({playSoundOnly:true}); | ||
| 24 | + data = $H(data); | ||
| 25 | + data = data.merge({playSoundOnly:true}); | ||
| 26 | 26 | } else if( data.notificationType == this.Messaging.notificationTypes.sendFailure) { | |
| 27 | 27 | data = {}; // wipe out the notification because we are in the chat | |
| 28 | 28 | } | |
| … | … | ||
| 30 | 30 | =================================================================== | |
| 31 | 31 | --- .orig/usr/palm/applications/com.palm.app.messaging/app/models/messaging-luna-service.js | |
| 32 | 32 | +++ /usr/palm/applications/com.palm.app.messaging/app/models/messaging-luna-service.js | |
| 33 | @@ -993,5 +993,170 @@ var MessagingMojoService = { | ||
| 33 | @@ -993,5 +993,168 @@ var MessagingMojoService = { | ||
| 34 | 34 | method: 'setSMSCAddressAndEmailGateway', | |
| 35 | 35 | parameters: {smscAddr:address, emailGateway: gateway} | |
| 36 | 36 | }); | |
| 37 | - } | ||
| 38 | -}; | ||
| 39 | \ No newline at end of file | ||
| 40 | 37 | + }, | |
| 41 | + | ||
| 42 | + isNumberValid: function(number) { | ||
| 38 | + | ||
| 39 | + isNumberValid: function(number) { | ||
| 43 | 40 | + return !(number === undefined | |
| 44 | + || number == null | ||
| 45 | + || number == "" | ||
| 46 | + || number == "unknown" | ||
| 47 | + || number == "unknown caller" | ||
| 48 | + || number == "blocked caller") | ||
| 41 | + || number == null | ||
| 42 | + || number == "" | ||
| 43 | + || number == "unknown" | ||
| 44 | + || number == "unknown caller" | ||
| 45 | + || number == "blocked caller") | ||
| 49 | 46 | + }, | |
| 50 | + | ||
| 51 | + // use contacts service and carrier book to perform reverse lookup on number.stores results in passed contact object. | ||
| 47 | + | ||
| 48 | + // use contacts service and carrier book to perform reverse lookup on number. stores results in passed contact object. | ||
| 52 | 49 | + // runs callback when done. | |
| 53 | 50 | + // if the number isn't valid, marks contact lookup complete | |
| 54 | 51 | + // if there's already one happening, or one already completed, just fires callback | |
| 55 | 52 | + // if there's a lateCallback provided, calls that if the result comes much later | |
| 56 | 53 | + rLookup: function(number, contact, callback, lateCallback){ | |
| 57 | + | ||
| 54 | + | ||
| 58 | 55 | + //Reset contact to always get the tone | |
| 59 | + contact = {}; | ||
| 56 | + contact = {}; | ||
| 60 | 57 | + Mojo.Log.error("Current contact value: %j",contact); | |
| 61 | 58 | + Mojo.Log.error("SMS ID: %j",number); | |
| 62 | + | ||
| 59 | + | ||
| 63 | 60 | + // bail if the number is invalid | |
| 64 | 61 | + if (!(this.isNumberValid(number))) { | |
| 65 | + this.finishLookup(contact, callback); | ||
| 66 | + return; | ||
| 62 | + this.finishLookup(contact, callback); | ||
| 63 | + return; | ||
| 67 | 64 | + } | |
| 68 | + | ||
| 65 | + | ||
| 69 | 66 | + if (contact.lookupComplete) { | |
| 70 | + callback(contact); | ||
| 67 | + callback(contact); | ||
| 71 | 68 | + return; | |
| 72 | 69 | + } | |
| 73 | + | ||
| 70 | + | ||
| 74 | 71 | + if (contact.lookupPending) { | |
| 75 | + callback(contact); | ||
| 72 | + callback(contact); | ||
| 76 | 73 | + return; | |
| 77 | 74 | + } | |
| 78 | + | ||
| 79 | + | ||
| 75 | + | ||
| 76 | + | ||
| 80 | 77 | + // use contacts service to perform lookup. | |
| 81 | 78 | + // if contact already has an id in it, use person lookup | |
| 82 | 79 | + // instead of doing reverse lookup on number | |
| … | … | ||
| 81 | 81 | + var method, params; | |
| 82 | 82 | + if (contact.initialId) { | |
| 83 | 83 | + method = 'basicDetails' | |
| 84 | + params ={'id' : contact.initialId} | ||
| 84 | + params = {'id' : contact.initialId} | ||
| 85 | 85 | + delete contact.initialId; | |
| 86 | 86 | + } else { | |
| 87 | 87 | + method = 'reverseLookup' | |
| 88 | 88 | + params = { | |
| 89 | + 'value': number, | ||
| 90 | + 'type': "phone" | ||
| 89 | + 'value': number, | ||
| 90 | + 'type': "phone" | ||
| 91 | + } | ||
| 91 | 92 | + } | |
| 92 | + } | ||
| 93 | 93 | + this.lastRequest = new Mojo.Service.Request('palm://com.palm.contacts', { | |
| 94 | 94 | + 'method': method, | |
| 95 | + parameters: params, | ||
| 96 | + onSuccess: this.onLookup.bind(this, number, contact, callback, lateCallback), | ||
| 95 | + parameters: params, | ||
| 96 | + onSuccess: this.onLookup.bind(this, number, contact, callback, lateCallback), | ||
| 97 | 97 | + onFailure: function() { | |
| 98 | + // cancel previous lookup, so this doesn't fire on a service crash | ||
| 99 | + if (this.lastRequest) { | ||
| 100 | + this.lastRequest.cancel(); | ||
| 101 | + this.lastRequest = undefined; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + this.carrierBookLookup(number,contact); | ||
| 105 | + this.finishLookup(contact, callback); | ||
| 106 | + }.bind(this) | ||
| 107 | + }); | ||
| 108 | + | ||
| 98 | + // cancel previous lookup, so this doesn't fire on a service crash | ||
| 99 | + if (this.lastRequest) { | ||
| 100 | + this.lastRequest.cancel(); | ||
| 101 | + this.lastRequest = undefined; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + this.carrierBookLookup(number,contact); | ||
| 105 | + this.finishLookup(contact, callback); | ||
| 106 | + }.bind(this) | ||
| 107 | + }); | ||
| 108 | + | ||
| 109 | 109 | + // timeout if lookup hasn't completed in 4 seconds | |
| 110 | 110 | + this.lookupTimeout = setTimeout(this.onLookupTimeout.bind(this, contact, callback, lateCallback), 4000); | |
| 111 | + }, | ||
| 112 | + | ||
| 113 | + // when contact lookup returns, check for valid result | ||
| 114 | + // if valid result, grab name, ringtone; if there's a picture, start loading and set callback to measure it | ||
| 115 | + // if no valid result, look in carrier book | ||
| 116 | + // fire callback when done | ||
| 117 | + onLookup: function(number, contact, callback, lateCallback, result){ | ||
| 118 | + Mojo.Log.info( "PhoneApp: Contact::onLookup CALLER ID LOOKUP %s RETURNED %j" , number , result); | ||
| 111 | + }, | ||
| 112 | + | ||
| 113 | + // when contact lookup returns, check for valid result | ||
| 114 | + // if valid result, grab name, ringtone; if there's a picture, start loading and set callback to measure it | ||
| 115 | + // if no valid result, look in carrier book | ||
| 116 | + // fire callback when done | ||
| 117 | + onLookup: function(number, contact, callback, lateCallback, result){ | ||
| 118 | + Mojo.Log.info( "PhoneApp: Contact::onLookup CALLER ID LOOKUP %s RETURNED %j" , number , result); | ||
| 119 | 119 | + var statusChange = ""; | |
| 120 | + | ||
| 120 | + | ||
| 121 | 121 | + // cancel previous lookup, so this doesn't fire on a service crash | |
| 122 | 122 | + if (this.lastRequest) { | |
| 123 | 123 | + this.lastRequest.cancel(); | |
| 124 | 124 | + this.lastRequest = undefined; | |
| 125 | 125 | + } | |
| 126 | + | ||
| 126 | + | ||
| 127 | 127 | + if (result.record) { | |
| 128 | + /* | ||
| 128 | + /* | ||
| 129 | 129 | + // don't match if the number we get back is different than the number | |
| 130 | 130 | + // we passed in (provided the lengths are the same) | |
| 131 | 131 | + if (!(result.record.number) | |
| 132 | 132 | + || ( (result.record.number) && ( (result.record.number.length !== number.length) | |
| 133 | + || (result.record.number.length === number.length | ||
| 134 | + && result.record.number === number)))) { | ||
| 135 | + */ | ||
| 136 | + contact.id = result.record.id; | ||
| 137 | + | ||
| 138 | + | ||
| 139 | + contact.ringtoneLoc = result.record.messagingRingtoneLoc; | ||
| 140 | + Mojo.Log.error("MSGTone: %j",contact.ringtoneLoc); | ||
| 141 | + | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + this.finishLookup(contact, callback, lateCallback); | ||
| 145 | + }, | ||
| 146 | + | ||
| 147 | + | ||
| 148 | + | ||
| 149 | + // mark complete; cancel timeout; fire callback if it hasn't fired yet | ||
| 150 | + finishLookup: function(contact, callback, lateCallback) { | ||
| 151 | + contact.lookupPending = false; | ||
| 152 | + | ||
| 153 | + // cancel lookup timeout | ||
| 154 | + clearTimeout(this.lookupTimeout); | ||
| 155 | + this.lookupTimeout = undefined; | ||
| 156 | + | ||
| 157 | + if (!(contact.lookupComplete)) { | ||
| 158 | + contact.lookupComplete = true; | ||
| 159 | + callback(contact); | ||
| 160 | + // if we have a late return, and we got a contact result, call | ||
| 161 | + // the late return update | ||
| 162 | + } else if (lateCallback && contact.doLateCallback && contact.id) { | ||
| 163 | + contact.doLateCallback = false; | ||
| 164 | + lateCallback.delay(5, contact); | ||
| 165 | + } else { | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + }, | ||
| 169 | + | ||
| 170 | + // flag lookup as done; proceed with callback | ||
| 171 | + onLookupTimeout: function(contact, callback, lateCallback) { | ||
| 172 | + | ||
| 173 | + if (lateCallback) { | ||
| 174 | + contact.doLateCallback = true; | ||
| 175 | + } else if (this.lastRequest && !lateCallback) { | ||
| 176 | + // cancel previous lookup, so this doesn't fire on a service crash | ||
| 177 | + this.lastRequest.cancel(); | ||
| 178 | + this.lastRequest = undefined; | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + // clear timeout | ||
| 182 | + this.lookupTimeout = undefined; | ||
| 183 | + | ||
| 184 | + // flag done; fire callback if it hasn't yet | ||
| 185 | + contact.lookupComplete = true; | ||
| 186 | + var lookupWasPending = contact.lookupPending; | ||
| 187 | + contact.lookupPending = false; | ||
| 188 | + if (lookupWasPending) | ||
| 189 | + callback(contact); | ||
| 190 | + }, | ||
| 191 | + | ||
| 192 | + getMessagetone:function(callback) { | ||
| 193 | + var request = new Mojo.Service.Request('palm://com.palm.systemservice', { | ||
| 194 | + method: 'getPreferences', | ||
| 195 | + parameters: {"keys":["messagetone"]}, | ||
| 196 | + onSuccess: callback, | ||
| 197 | + onFailure: callback | ||
| 198 | + }); | ||
| 199 | + return request; | ||
| 200 | + } | ||
| 133 | + || (result.record.number.length === number.length | ||
| 134 | + && result.record.number === number)))) { | ||
| 135 | + */ | ||
| 136 | + contact.id = result.record.id; | ||
| 137 | + | ||
| 138 | + | ||
| 139 | + contact.ringtoneLoc = result.record.messagingRingtoneLoc; | ||
| 140 | + Mojo.Log.error("MSGTone: %j",contact.ringtoneLoc); | ||
| 201 | 141 | + | |
| 202 | +}; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + this.finishLookup(contact, callback, lateCallback); | ||
| 145 | + }, | ||
| 146 | + | ||
| 147 | + | ||
| 203 | 148 | + | |
| 149 | + // mark complete; cancel timeout; fire callback if it hasn't fired yet | ||
| 150 | + finishLookup: function(contact, callback, lateCallback) { | ||
| 151 | + contact.lookupPending = false; | ||
| 152 | + | ||
| 153 | + // cancel lookup timeout | ||
| 154 | + clearTimeout(this.lookupTimeout); | ||
| 155 | + this.lookupTimeout = undefined; | ||
| 156 | + | ||
| 157 | + if (!(contact.lookupComplete)) { | ||
| 158 | + contact.lookupComplete = true; | ||
| 159 | + callback(contact); | ||
| 160 | + // if we have a late return, and we got a contact result, call | ||
| 161 | + // the late return update | ||
| 162 | + } else if (lateCallback && contact.doLateCallback && contact.id) { | ||
| 163 | + contact.doLateCallback = false; | ||
| 164 | + lateCallback.delay(5, contact); | ||
| 165 | + } else { | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + }, | ||
| 169 | + | ||
| 170 | + // flag lookup as done; proceed with callback | ||
| 171 | + onLookupTimeout: function(contact, callback, lateCallback) { | ||
| 172 | + | ||
| 173 | + if (lateCallback) { | ||
| 174 | + contact.doLateCallback = true; | ||
| 175 | + } else if (this.lastRequest && !lateCallback) { | ||
| 176 | + // cancel previous lookup, so this doesn't fire on a service crash | ||
| 177 | + this.lastRequest.cancel(); | ||
| 178 | + this.lastRequest = undefined; | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + // clear timeout | ||
| 182 | + this.lookupTimeout = undefined; | ||
| 183 | + | ||
| 184 | + // flag done; fire callback if it hasn't yet | ||
| 185 | + contact.lookupComplete = true; | ||
| 186 | + var lookupWasPending = contact.lookupPending; | ||
| 187 | + contact.lookupPending = false; | ||
| 188 | + if (lookupWasPending) | ||
| 189 | + callback(contact); | ||
| 190 | + }, | ||
| 191 | + | ||
| 192 | + getMessagetone: function(callback) { | ||
| 193 | + var request = new Mojo.Service.Request('palm://com.palm.systemservice', { | ||
| 194 | + method: 'getPreferences', | ||
| 195 | + parameters: {"keys":["messagetone"]}, | ||
| 196 | + onSuccess: callback, | ||
| 197 | + onFailure: callback | ||
| 198 | + }); | ||
| 199 | + return request; | ||
| 200 | } | ||
| 201 | }; | ||
| 202 | \ No newline at end of file | ||
| 204 | 203 | Index: /usr/palm/applications/com.palm.app.messaging/app/controllers/notification-assistant.js | |
| 205 | 204 | =================================================================== | |
| 206 | 205 | --- .orig/usr/palm/applications/com.palm.app.messaging/app/controllers/notification-assistant.js | |
| … | … | ||
| 213 | 213 | NotificationAssistant.prototype.subscribeToNotifications = function(){ | |
| 214 | 214 | this.messageNotificationRequest = MessagingMojoService.registerForIncomingMessages({onSuccess: this.sendNotification.bind(this, this.Messaging.notificationTypes.newMessage)}); | |
| 215 | 215 | this.sendErrorNotificationRequest = MessagingMojoService.registerForSendFailures(this.sendNotification.bind(this, this.Messaging.notificationTypes.sendFailure)); | |
| 216 | @@ -51,6 +53,37 @@ NotificationAssistant.prototype.sendNoti | ||
| 217 | } | ||
| 216 | @@ -35,6 +37,37 @@ NotificationAssistant.prototype.subscrib | ||
| 217 | this.airplaneModeNotificationRequest = MessagingMojoService.registerForAirplaneModeNotifications(this.sendAirplaneModeNotification.bind(this)); | ||
| 218 | 218 | }; | |
| 219 | 219 | ||
| 220 | 220 | +NotificationAssistant.prototype.doBanner = function(bannerParams,bannerLaunchParams,bannerType,payload) { | |
| … | … | ||
| 232 | 232 | + | |
| 233 | 233 | +NotificationAssistant.prototype.doB = function(bannerParams,bannerLaunchParams,bannerType,contact) { | |
| 234 | 234 | + Mojo.Log.error("Banner Ringtone: %j",contact.ringtoneLoc); | |
| 235 | + if (contact.ringtoneLoc) { | ||
| 236 | + bannerParams.soundFile = contact.ringtoneLoc; | ||
| 237 | + this.controller.showBanner(bannerParams,bannerLaunchParams,bannerType); | ||
| 238 | + } else { | ||
| 239 | + MessagingMojoService.getMessagetone(this.doBanner.bind(this,bannerParams,bannerLaunchParams,'chat')); | ||
| 240 | + } | ||
| 235 | + if (contact.ringtoneLoc) { | ||
| 236 | + bannerParams.soundFile = contact.ringtoneLoc; | ||
| 237 | + this.controller.showBanner(bannerParams,bannerLaunchParams,bannerType); | ||
| 238 | + } else { | ||
| 239 | + MessagingMojoService.getMessagetone(this.doBanner.bind(this,bannerParams,bannerLaunchParams,'chat')); | ||
| 240 | + } | ||
| 241 | 241 | +}; | |
| 242 | + | ||
| 242 | + | ||
| 243 | 243 | +NotificationAssistant.prototype.playmsgtone = function(contact){ | |
| 244 | + Mojo.Log.error("Playmsgtone Ringtone: %j",contact.ringtoneLoc); | ||
| 245 | + if (contact.ringtoneLoc) | ||
| 246 | + this.controller.playSoundNotification('alerts',contact.ringtoneLoc); | ||
| 247 | + else | ||
| 248 | + MessagingMojoService.getMessagetone(this.playMessagetone.bind(this)); | ||
| 244 | + Mojo.Log.error("Playmsgtone Ringtone: %j",contact.ringtoneLoc); | ||
| 245 | + if (contact.ringtoneLoc) | ||
| 246 | + this.controller.playSoundNotification('alerts',contact.ringtoneLoc); | ||
| 247 | + else | ||
| 248 | + MessagingMojoService.getMessagetone(this.playMessagetone.bind(this)); | ||
| 249 | 249 | +}; | |
| 250 | 250 | + | |
| 251 | /* | ||
| 252 | * <ReminderCode> | ||
| 253 | */ | ||
| 251 | NotificationAssistant.prototype.sendNotification = function(notificationType, resp){ | ||
| 252 | if (window.PalmSystem && !resp.returnValue) { | ||
| 253 | try { | ||
| 254 | 254 | @@ -140,7 +173,8 @@ NotificationAssistant.prototype.consider | |
| 255 | 255 | ||
| 256 | 256 | // check if we should only play a sound (when you are already in a chat & a new message comes in) | |
| 257 | 257 | if(notificationData.get('playSoundOnly') && this.Messaging.messagingPrefs.enableNotificationSound) { | |
| 258 | 258 | - this.controller.playSoundNotification('alerts',''); | |
| 259 | 259 | + var smsid = notificationData.get('address'); | |
| 260 | + MessagingMojoService.rLookup(smsid,contact,this.playmsgtone.bind(this),this.playmsgtone.bind(this)); | ||
| 260 | + MessagingMojoService.rLookup(smsid,contact,this.playmsgtone.bind(this),this.playmsgtone.bind(this)); | ||
| 261 | 261 | return; // don't display any visual notification | |
| 262 | 262 | } | |
| 263 | 263 | ||
| … | … | ||
| 275 | 275 | var class0Stage = this.controller.getStageController(Class0AlertStageName); | |
| 276 | 276 | ||
| 277 | 277 | if(class0Stage) { | |
| 278 | @@ -188,6 +223,9 @@ NotificationAssistant.prototype.renderCl | ||
| 278 | @@ -188,6 +223,8 @@ NotificationAssistant.prototype.renderCl | ||
| 279 | 279 | var soundClass = 'none'; | |
| 280 | 280 | if(playSound) { | |
| 281 | 281 | soundClass = 'alerts'; | |
| 282 | 282 | + if(messageTone) | |
| 283 | 283 | + soundFile = messageTone; | |
| 284 | + } | ||
| 285 | 284 | } | |
| 286 | 285 | ||
| 287 | 286 | var pushClass0AlertScene = function(stageController) { | |
| 288 | @@ -198,7 +236,8 @@ NotificationAssistant.prototype.renderCl | ||
| 287 | @@ -198,7 +235,8 @@ NotificationAssistant.prototype.renderCl | ||
| 289 | 288 | name: Class0AlertStageName, | |
| 290 | 289 | lightweight: true, | |
| 291 | 290 | height: 300, | |
| … | … | ||
| 294 | 294 | }, pushClass0AlertScene, 'popupalert'); | |
| 295 | 295 | } | |
| 296 | 296 | ||
| 297 | @@ -253,8 +292,6 @@ NotificationAssistant.prototype.sendNewM | ||
| 297 | @@ -253,8 +291,6 @@ NotificationAssistant.prototype.sendNewM | ||
| 298 | 298 | var bannerParams = { | |
| 299 | 299 | messageText: notificationText | |
| 300 | 300 | }; | |
| … | … | ||
| 303 | 303 | var bannerLaunchParams = { | |
| 304 | 304 | chatThreadId: chatThreadId, | |
| 305 | 305 | clearBanner: true | |
| 306 | @@ -262,10 +299,16 @@ NotificationAssistant.prototype.sendNewM | ||
| 306 | @@ -262,10 +298,17 @@ NotificationAssistant.prototype.sendNewM | ||
| 307 | 307 | ||
| 308 | 308 | if (this.Messaging.DisplayState.isDisplayOn()) { | |
| 309 | 309 | Mojo.Log.info("notificationAssistant - executing full banner notification"); | |
| 310 | 310 | - this.controller.showBanner(bannerParams, bannerLaunchParams, 'chat'); | |
| 311 | 311 | + if (this.Messaging.messagingPrefs.enableNotificationSound) { | |
| 312 | + var smsid = notificationData.get('address'); | ||
| 312 | + var smsid = notificationData.get('address'); | ||
| 313 | 313 | + bannerParams.soundClass = "alerts"; | |
| 314 | 314 | + MessagingMojoService.rLookup(smsid,contact,this.doB.bind(this,bannerParams,bannerLaunchParams,'chat'),this.doB.bind(this,bannerParams,bannerLaunchParams,'chat')); | |
| 315 | 315 | + } else { | |
| 316 | + Mojoa.Log.error("Setting banner params"); | ||
| 316 | 317 | + this.controller.showBanner(bannerParams, bannerLaunchParams, 'chat'); | |
| 317 | 318 | + } | |
| 318 | 319 | } else if (this.Messaging.messagingPrefs.enableNotificationSound) { | |
| 319 | 320 | - Mojo.Log.info("notificationAssistant - playing sound notification only"); | |
| 320 | 321 | - this.controller.playSoundNotification('alerts',''); | |
| 321 | + var smsid = notificationData.get('address'); | ||
| 322 | + var smsid = notificationData.get('address'); | ||
| 322 | 323 | + MessagingMojoService.rLookup(smsid,contact,this.playmsgtone.bind(this),this.playmsgtone.bind(this)); | |
| 323 | 324 | } | |
| 324 | 325 |

