December 30, 2008
This posting is also available as a page on the QuickConnect wiki
Because QuickConnectiPhone, like the other members of the QuickConnectFamily, is an application framework much of what you would normally need to do to create and application is already done for you. It is modular in nature and handles all of the communication between the modules. You create your functionality as discrete mini-modules that either interact with, get, or set data, display information, or do validation of data. These mini-modules are then called by the framework in the order that you state in response to ahandleRequest function call. Below are the three steps followed when adding or creating functionality for your application. These steps are the same for all members of the QuickConnectFamily of frameworks. Follow these steps.
- Call the handleRequest function as the result of an event. You can either make the linkage between the event directly or from within an event handler that Dashcode creates for you. There are two parameters for the handleRequest function.
- aCmd – a string that is a command indicator. These should be unique to the functionality you desire to be executed.
- paramArray – an array of parameters that you want to be available later in the code that will handle the request. These could be, but are not limited to, the object triggering the event, an event object, or anything else you may need.
- An example of calling this function would be handleRequest(‘userData’) which could cause data to be retrieved and displayed.
- Create one or more mappings of the command to specific functions you want called every time handleRequest is passed the command. These mapping calls are made in the mappings.js file included in the framework. There is a different mapping function for each type of mini-module. All of these mapping functions have two parameters.
- aCmd – a string that is the command the mini-module is to be mapped to. This corresponds with the aCmd parameter ofhandleRequest.
- aControlFunction – a mini-module of the correct type, see below, that the framework is to call when the command is passed to handleRequest.
- mapCommandToBCF – maps your command to a mini-module that will get, set, or manipulate data called a Business Control Function (BCF). You can have any number of these mappings in a row for a command. The framework calls them in the order that you put them in the file.
- mapCommandToVCF – maps your command to a min-module that displays data or modifies the user interface in some way called a View Control Function (VCF). You can have any number of these mappings in a row for a command. The framework calls them in the order that you put them in the file.
- mapCommandToValCF – maps your command to a mini-module that you use to validate the parameters passed to the handleRequest function called a Validation Control Function (ValCF). You can have any number of these mappings in a row for a command. The framework calls them in the order that you put them in the file. an example of a ValCF would be one for a login command that validated the user name and password included in the paramArray of thehandleRequest function.
- mapCommandToECF – maps your command to a mini-module used to handle errors called an Error Control Function (ECF).You can have any number of these mappings in a row for a command. The framework calls them in the order that you put them in the file. To follow the login command example used in #3, if the user name or password failed validation for some reason any ECF’s that you map to the login command will be called by the framework on validation failure. You could then display some helpful message for the user.
Download QCiPhone version 1.1 from here.
It includes the installer as well as new example code for the new features. See how to access a SQLite database, either shipped on the device or in the UIWebView object, by making a few simple calls. Start by looking in the mappings.js file and then the functions.js file to see how easy it is to do. The nativeDBAccess example includes a sample.sqlite database file. The browserDBAccess example shows you how to create and populate a SQLite database within the UIWebView without having any database files.
The browserAJAXAccess example is a simplified example that pulls data from the RSS feed for this blog. Again, look in the mappings.js and functions.js files to see how to do this.
Want to know how the linearization happens? Look in the QuickConnect.js file and search for the dispatchToBCF function. Then check out the DataAccessObject.js and ServerAccessObject.js files.
All of this, in addition to coverage of PhoneGap will be covered in my upcoming book from Pearson Publishing.
I have also linearized the asynchronous calls that you make to the device or remote servers using AJAX. This required some changes to the PhoneDataAccessObject, now renamed DataAccessObject, as well as the ServerAccessObject used for AJAX calls.
In other words, now you can make a call to an SQLite database, an AJAX server, or GPS location information, and then make a call to any other piece of functionality and the second call will not happen until the first asynchronous call has completed. This has been one of the most requested feature changes. You no longer need worry about the timing of your asynch calls. String together any number of asynchronous calls and the framework will ensure that they happen linearly.
Another change is that the QueryResult object is used as the data return for both database calls and AJAX calls. Regardless of the type of call the returned objects are the same.
These major changes are what bumped the version number up to 1.1.
December 23, 2008
With this in mind, there are a few items that with out question are going to be in the upcoming version 1.5 of QuickConnectiPhone.
- Network communication to applications running on a Mac via the iPhone synch cable
The development of #1 is nearing completion and is undergoing testing.
#2 is fully designed and ready for development.
#3 is also fully designed and ready for development.
These 3 items, along with the existing AJAX wrapper already available give you the full range of networking capabilities available to any iPhone developer/ application designer.
Other items still undergoing review for possible inclusion are:
- Access to the contacts API
- Using the camera
Additional feedback for possible inclusion would be greatly appreciated.
December 16, 2008
The 1.0 release version of QuickConnectiPhone is now available for download from SourceForge.
(See the 1.5 release announcement on this blog to see what additional features and examples have been added.)
- Get browser based database access
- Get access to databases shipped with or created by your application
- Get GPS location information
- Get device acceleration information
- Show and use native Date and Date/Time pickers
- Vibrate the device
- Record and playback audio
- Play system sounds such as the notification sound
- Use a prebuilt drag and drop framework to easily make any DOM object draggable
- Use a prebuilt scaling and rotation framework to easily make any DOM object resizable and rotatable.
Examples for all capabilities are included in the Examples directory included in the download.
The QuickConnectFamily image Copyright Lee Barney 2008. All rights reserved.
It looks like I’m going to be getting some help with QuickConnectiPhone. A gracious individual is working on adding Bonjour network access for QuickConnectiPhone. You should be able to display, select, send data to, and get data from other networked devices.
So, I have been porting QuickConnectiPhone to the Google phone and I came across an interesting tidbit. The version of WebKit that is used in the WebView for the Google phone is incomplete when compared to the iPhone version. It doesn’t have a SQLite database built in. This is truly a shame. I’m now wondering if they left out the CSS animation as well. That would be just as bad.
December 7, 2008
To aid you in developing your QuickConnect iPhone and other types of apps a Google group has been created.
A twitter has also been created for quick and easy postings/questions/answers.
I hope this helps you in doing your development.
December 5, 2008
I have now written access code for the SQLite database in a few languages and on various platforms. There is a dramatic difference in the ease of use from a programmers perspective.
The easiest to use, strangely enough, are the Objective-C classes from Apple and the C++ classes from QT(Nokia).
You would think that with the programmer friendly API of Google’s Android that SQLite access would be easy. In fact, I assumed that it would be somewhat similar to JDBC. It is not. I find it particularly nasty since none of the classes are familiar and you have to work out the class relationships all over again. That would be fine if there was one nice main class as in the Apple and QT implementations but there are not.