This article explains the basic structure of Pandion's source code. You can access the source code by following the steps in this article: Getting the Source Code
The Pandion application consists of the Client and the Host. There is an Installer sub-project to build a distributable setup package (*.msi). The Appcaster utility is included to generate an auto-update feed.
Host
The Host is a rich desktop application framework that loads HTML/CSS/JavaScript and exposes operating system functionality to the JavaScript layer. The Host is written in C++ and can be compiled using Microsoft Visual C++ 2010 Express or Professional editions. Microsoft Visual C++ 2010 Express can be downloaded at no cost from http://www.microsoft.com/express/. Installing different Visual Studio/C++ versions (or editions) next to each other poses no problem.
Manual Building: Generic
Open /Host/Host.sln in Visual C++ and press Ctrl+Shift+B to build the application. Use Ctrl+F5 to run your build like any other application. Build dependencies are the Microsoft platform SDK and the libraries bundled with Visual C++, both should be readily available if Visual C++ was installed correctly. The project also has zlib as a build dependency and a precompiled version is bundled with the pandion code on github.
Automated Building: Branded
To change the name and meta information of the executable, use the provided /Host/build_host.bat batch script. The branding can be customised in the /build_config.bat batch script.
Build Configurations
There are 2 project build configurations: Debug and Release. Use Release to deploy your application for real-world usage and use Debug for testing while developing. The Release build will generate Host.exe, and the Debug build will generate Host_debug.exe to clearly distinguish it. Both build scripts will also generate Host[_debug].pdb files, more information about those files can be found at MSDN.
Debugging
If you have built the debug version you can press F5 to run your build attached to the Visual C++ debugger. You can press F9 anywhere in the source code to toggle debug breakpoints and use F10 and F11 for respectively stepping in or stepping over the source code once a breakpoint was hit.
Running
The output executable will be placed at /Client/Host[_debug].exe. Upon launch the Host will create a hidden window that embeds the Internet Explorer WebBrowser control and loads src/main.html relative to its own location automatically.
Client
The Client is the user interface and application logic that drives Pandion. To launch the Client you need to place Pandion.exe (or Host.exe) in the /Client directory. Get a copy of Pandion.exe by compiling the Host as described above, or take Pandion.exe from the distributable on the Pandion website. If you have already installed Pandion you will find it in %ProgramFiles(x86)%\Pandion\Pandion.exe.
Editing
Use any text editor (Notepad++, Aptana, EditPlus, ...) to edit the Client source code. The application flow starts with main.html which loads all JavaScript files in /Client/src/main/.*js and has an onload event handler set for init() which is found in /Client/src/main/init.js
To test your changes simply re-open the dialog you have edited or restart Pandion. There is no need to recompile the Host.
Debugging
While you could simply spray your source code with alert() calls to hunt bugs, it's generally easier to use a debugger. The Microsoft Script Debugger is free of charge but you can also use Visual Studio's Script Debugger.
Once you have installed either of these script debuggers, open Internet Explorer and uncheck this inversely named option: Tools->Internet Options…->Advanced->Disable Script Debugging (Other)
Now any JavaScript error in Pandion will trigger the debugger. You can also launch the JavaScript debugger from code by using the "debugger;" keyword.
File Hierarchy
The source code is separated along the Model-View-Controller (MVC) pattern. The data (model) is defined in JavaScript files, the skin (view) is specified in CSS, and the UI widgets (controller) are declared in HTML. This language separation enforces loose coupling and best coding practices. There should not be any use of inline CSS or JavaScript in the HTML and no HTML should be declared in the JavaScript. Note: Some legacy code does not follow this guideline yet and needs to be refactored.
Each dialog in Pandion has its own filename. For example: the About dialog.
- /Client/src/about.html
- /Client/js/about.js
- /Client/css/about.css
Resources go in their respective directories:
| /Client/js |
Model, business logic. Each dialog's JavaScript source code is defined in [dialogName].js |
| /Client/css |
View, UI styling. The default theme for a dialog is specified in [dialogName].css |
| /Client/src |
Controller, UI widgets. Elements used in a dialog are declared as HTML in [dialogName].html |
| /Client/js/lib |
Various JavaScript helper libraries. |
| /Client/css/lib |
Common skin styles, CSS reset, etc. |
| /Client/src/main |
Legacy JavaScript code. Almost all loaded by main.html and some shared by other dialogs. Needs refactoring. |
| /Client/avatars |
Contains the default set of avatars.
Each file contains a PNG/GIF/JPEG image.
File names are the SHA-1 hashes of the binary file data.
These files are copied on Pandion launch to %APPDATA%/Pandion/Avatars
|
| /Client/emoticons |
Contains the default emoticon styles.
*.jisp files can be inspected using any ZIP tool.
All JISP files are extracted on Pandion launch to %APPDATA%/Pandion/Emoticons
|
| /Client/images |
Contains various image resources used in the Pandion GUI.
These images are referenced by the CSS.
|
| /Client/languages |
Contains all the translations for Pandion (*.xml)
Also contains instructions for contributors and a language comparison tool (compare.hta).
|
| /Client/settings |
bookmarks.xml
Contains a list of conference rooms that are bookmarked by default for each user.
Copied on profile creation to %APPDATA%/Pandion/Profiles/[user@server]
brand.xml
Application configuration values that are loaded at runtime into external.globals
default.xml
Standard settings for each user profile.
Settings are stored per user in %APPDATA%/Pandion/Profiles/[user@server]
servers.xml
List of XMPP servers for the sign-up wizard and MUC services for conference room creation.
|
| /Client/sounds |
Default sound effects for application events (new message, contact online) |
Bridge to the Host
The Client's JavaScript code communicates with the Host through the "external" object.
For example:
<script type="text/javascript">
external.wnd.messageBox(false, "Hello World", "My Dialog Title", 0 | 48);
</script>
The Host exposes many APIs. To learn their functionality either look at the Host source code or use the OLE/COM Object Viewer development tool which is available from Microsoft. In the tool go to Type Libraries and scroll down to PandionLib. Double click it to inspect the various interfaces exposed by the Host to the Client.
Installer
After modifying Pandion you may want to package it for distribution. The official Pandion installer is an MSI file for Windows Installer. The MSI is created using Windows Installer XML (WiX), a free and open source tool. The advantage of MSI files is that they can be edited and deployed easily by network administrators across an Active Directory (AD) domain using Group Policy Objects (GPO).
Creating the Package
Before attempting to create the package, the Host source code must be compiled in its release version. See the above Host section for instructions.
- Pandion requires WiX 3.5 to be installed successfully.
- Add the WiX "bin" directory to your PATH system environment variable. Open "Control Panel > System and Security > System > Advanced system settings > Advanced > Environment Variables" and append the full path to the bin directory to the PATH variable.
- Open a console: Start menu > Run > cmd.exe
- Enter: cd /path/to/pandion/code/Installer/WiX
- Run: build_msi.bat
The result is an MSI package called Pandion_2.6.0.msi or similar. The build script is designed to integrate with Hudson continuous integration server.
Comments (0)
You don't have permission to comment on this page.