[Windows Mobile Development and Hacking General] AppStar:
AppStar Titanium

Plug-in Installer

This program allows chome/titanium plug-in developers to create a cab file that will insert the plug-in's markup into the cpr files depending on the device's resolution and update the registry without overriding any of the user's existing chome/titanium configuration files or settings.

Device Requirements:

1. WM 6.5

2. .Net CF 2.0 or higher

Usage:

First things first, this is a developer only tool that has strict requirements to work properly. It requires a few files to be deployed and files like the plg files are case sensitive. ATPluginInstaller.exe and CESetupDLL.dll can be used for any free, not for profit, chome/Titanium plug-in.

Ok, now onto the fun stuff...

ATPluginInstaller.exe is the program where most of the magic happens. It does a few important things. First, it adds a plug-in name to the registry in "HKEY_LOCAL_MACHINE\Software\Microsoft\CHome:Plugins" and also inserts the plug-in into the specified location in "HKEY_LOCAL_MACHINE\Software\Microsoft\CHome:ExtensibilityXML" and "DefaultXML". Then it clears all VALUES in "HKEY_LOCAL_MACHINE\Security\CHome\DefaultSettings" to prevent chome from reverting to an old layout. Finally it injects the appropriate markup for the device resolution into each of the Titanium CPR files.

For ATPluginInstaller.exe to know what plug-in and markup to use, it needs a PLG file. A PLG file is basically a pre-defined XML file that includes the name, position, and markup for the plug-in you want to install.

Begining of a sample PLG file:

<?xml version="1.0" encoding="utf-8" ?>
<plugin>
<name>ATFavePeople</name>
<position>2</position>
<layouts>
<layout screenWidth="240" screenHeight="320">
<!-- ATFavePeople -->
<Layer ID="ATFavePeopleExpanded" Visible="False" Width="240" Height="82" Clip="False">
<Layer ID="Page" Clip="False">
<!-- Icon on upper right -->
<Image ID="Icon" Left="188" Top="-13" Width="43" Height="57" ScaleStyle="Stretch"/>
<!-- Large picture in Center -->
<Image ID="ContactPhoto" Left="10" Top="17" Width="43" Height="43" ScaleStyle="Fit" Clip="False">
<Layer ID="Border2" Color="#FFFFFFFF" Left="-2" Top="-2" Width="90" Height="90" Visible="True"/>
</Image>
(abbreviated to conserve space...)

The root node is "plugin". The three sub-nodes are "name", "position", and "layouts". All nodes must follow case to work with ATPluginInstaller.exe.

The "name" node contains the name of the plug-in you wish to install. It must match the name used in the plug-in markup.

The "position" node specifies where you want the plug-in to be displayed on chome. It is 0 based. Meaning the first spot is 0, the second spot is 1, and so on. If a number greater than the number of currently installed plug-ins is used, then the plug-in will be displayed at the bottom of chome.

The "layouts" node contains all the plug-in markup for the different device resolutions. Each resolution is defined by a "layout" sub-node with two attributes. The attributes are "screenWidth" and "screenHeight" which define what "layout" sub-node to use for each resolution. The "layout" sub-node contains the markup that will be injected into the CPR files. This markup is also case sensative and must follow the case that is used by Microsoft in the default CPR files or the sample attached PLG file.

To install a plug-in, simply call ATPluginInstaller.exe followed by the "-i" parameter and a space and then the PLG file name.

example: ATPluginInstaller.exe -i default.plg

ATPluginInstaller.exe is also uninstall friendly. Just replace "-i" with "-u".

example" ATPluginInstaller.exe -u default.plg

Well that's fine and dandy, but how the hell do I call ATPluginInstaller.exe from my CAB file? That's where a setup DLL comes into play. A setup DLL allows you to execute additional functions after a program is installed and before it is uninstalled. Working with setup DLLs are a pain in the butt because they don't support managed code, only C++. So I've attached CESetupDLL which is a setup dll that does two things:

1. It calls ATPluginInstaller.exe and installs, "-i", default.plg from the folder where the application is deployed to.

2. It calls CHomeRefresh.exe from the folder where the application is deployed to, to update Chome without performing a restart. (I didn't write CHomeRefresh and don't know who did but it works fairly well.)

CESetupDLL also works for CAB uninstall.

To include your CESetupDLL.dll in the INF file (file used to build installation CAB file) you have to add the following string to the [DefaultInstall] section:

CESetupDLL = "CESetupDLL.dll"

You can read more about setup.dlls here:

http://www.pocketpcdn.com/articles/setupdll.html

http://msdn.microsoft.com/en-us/library/aa924308.aspx

That's pretty much it! Remember to pay attention to case, and if you use my CESetupDLL.dll include ATPluginInstaller.exe, default.plg, and CHomeRefresh.exe to your program folder in your CAB.

Feel free to use ATPluginInstaller.exe and CESetupDLL.dll for any free, not for profit, chome/Titanium plug-in. Giving me some credit would be nice too. ;-)