Patch webOS Email App Patch to Prompt for IPK Installation

From WebOS Internals

Revision as of 08:54, 3 August 2009 by Hopspitfire (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Preamble

You will need write permissions to the filesystem on your pre to apply this patch.

To get write persmissions execute:

rootfs_open -w

To remount the filesystem as read-only:

mount -o remount,ro /

Procedure

I have patched the email application to prompt for installation. It involves modifying/replacing the handleLinkClicked function inside the following file:

/usr/palm/applications/com.palm.app.email/app/controllers/message-assistant.js

Be sure to make a backup of your message-assistant.js before modifying it.

simplyflipflops

This patch is available at http://gitorious.org/webos-internals/modifications/blobs/raw/master/email/prompt-for-ipk-installation.patch

It is as follows:

 
  /**
   * User clicked on a hyperlink.
   */
  handleLinkClicked: function(event) {
    Mojo.Log.info("handleLinkClicked %s", event.url);

    var extensionIndex2 = event.url.lastIndexOf('.');
    if (extensionIndex2 > 0 ){
      var extensionTemp = event.url.substring(extensionIndex2 +1).toLowerCase();
    }
    
    if (extensionTemp === "ipk") {
      this.controller.showAlertDialog({
          onChoose: function(value) { 
            if (value===true) {
              this.controller.serviceRequest('palm://com.palm.applicationManager',
                  {
                    method: 'open',
                    parameters: {target: event.url}
                  });
            }
          },
          
          message: $L("Found Palm Application Bundle IPK. You should only install packages from trusted sources."),

          choices: 
            [
              {label:$L('I Trust This Source - Install'), value: true, type:'affirmative'},
              {label:$L('Cancel Install'), value: false, type:'alert'}
            ]
      });
    } else {
      this.controller.serviceRequest('palm://com.palm.applicationManager',
          {
            method: 'open',
            parameters: {target: event.url}
          });
    }
  },

Notes

Confirmed as working by FXDemolisher

BUT noticed by ultraBlack that even when one clicks Cancel, the app installs itself, rendering this useless.

NOTE: (06-27-2009) - Retested again with the tip calculator app, the cancel button prevents installation on firmware 1.0.3. Went over the code once more, i don't see how its possible that the cancel button would still install the app. Can anyone provide a test case where cancel still installs? - FXDemolisher

--Cancel worked for me as well on 1.0.3. - jhoff80

Should be noted that this can only help if the package has an ipk extension. If Luna will automatically install files without the ipk extension that it determines to be packages, they will be missed by this check.

ultraBlack: I don't know; I probably did something wrong. edit: Found what I (ultraBlack) was doing wrong. The app only installs if it's already been installed before (it updates). If the app hasn't been installed before, the cancel button works as intended. When I deleted the icon of the app I was testing from the launcher, the app was still in /var/usr/palm/applications, but once I deleted both the icon and the app's folder in /var/usr/palm/applications, the cancel button worked correctly, and the app was not installed. I suppose I should use the software listing to delete apps, rather than the launcher. That method probably actually removes the app rather than just the icon.

ultraBlack: I updated my code to explain what I did above:

          message: $L("Found Palm Application Bundle IPK. You should only install packages from trusted sources. Note: If an app already actually exists in the proper directory, it is already being updated. If there is no icon in the launcher for it, one will be re-added. If this is the case, hitting cancel below will do nothing."),

          choices:
            [
              {label:$L('Install'), value: true, type:'affirmative'},
              {label:$L('Cancel'), value: false, type:'alert'}
            ]

Update: Deleting the app I was testing with (Tip Calculator) from the apps/software listing on the phone does not remove the app's folder (org.jwz.tipcalculator) from /var/usr/palm/applications. Perhaps this is simply a problem with the Tip Calculator. - ultraBlack again

Personal tools
Google AdSense