December 30, 2008

A Quick Reference for how to create QuickConnectiPhone applications

Posted in iPhone development tagged , , , at 8:24 pm by tetontech

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.

  1. 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.
    1. aCmd – a string that is a command indicator.  These should be unique to the functionality you desire to be executed.
    2. 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.
    3. An example of calling this function would be handleRequest(‘userData’) which could cause data to be retrieved and displayed.
  2. 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.
    1. aCmd – a string that is the command the mini-module is to be mapped to.  This corresponds with the aCmd parameter ofhandleRequest.
    2. aControlFunction – a mini-module of the correct type, see below, that the framework is to call when the command is passed to handleRequest.
      1. 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.
      2. 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.
      3. 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.
      4. 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.
  3. Create the mini-modules to be called as listed in the mappings for the command.  These are implemented in the functions.js file as standard JavaScript functions.  There is a suggested naming convention.  The name should end with the shorthand for the type of mini-module it is.  For example, a Business Control Function doing a login check would be called loginBCF.  Each one of these functions should do one thing.  Remember that you can have any number of them and the framework will call them for you in the sequence you defined the mappings in the mappings.js file.  BCF’s and ValCF’s are always created with one parameter.  The framework uses this parameter to pass your BCF the parameters array you created and passed to the handleRequest function.  VCF’s are always created with two parameters.  The first will be the data accumulated by the calls to your BCF’s and the second is the same parameters array that was passed to your BCF’s and ValCF’s.  ECF’s also have one parameter.  It is a descriptor string for the error.  You con choose to use it in your control function or not. Examples of these types of control functions are available in the Examples directory of the download.

QuickConnectiPhone version 1.1 is now available

Posted in iPhone development tagged , , , , , , , , , , , , , , , , , , at 12:31 am by tetontech

QuickConnectFamily

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.

If you want to know how the framework pulls all of this off have a look in the com.js file.  It handles the communication to the device for everything from database access to debug messages and error logging.  If you want to get even deeper you can check out the Objective-C classes that support the JavaScript device calls.

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.

As stated above, version 1.1’s new abilities include a full implementation to access any number of SQLite databases shipped with your application from within JavaScript.  This uses the same getData, setData API that version 1.0 used to access SQLite databases in the UIWebVeiw with one modification.  If you want to get or set data in a ‘native’ database instead of in the UIWebView you use the getNativeData and setNativeData methods.  Everything else is exactly the same between the two types of calls.

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

QuickConnectiPhone version 1.5 development update

Posted in iPhone development tagged , , , , , , , , , , at 5:40 pm by tetontech

The reason for the existence of QuickConnectiPhone is to allow you through JavaScript to use all of the functionallity available to Objective-C programmers.

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.

  1. JavaScript control of Bonjour services discovery and network communication (wireless)
  2. Network communication to applications running on a Mac via the iPhone synch cable
  3. The ability to launch your JavaScript application from other applications using custom URL types

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:

  1. Access to the contacts API
  2. Using the camera
  3. ?????

Additional feedback for possible inclusion would be greatly appreciated.

December 16, 2008

QuickConnectiPhone 1.0 Release has shipped.

Posted in iPhone development, mac development, misc, PHP development tagged , , , , , , , , , , , , , , , , at 9:00 pm by tetontech

QuickConnectFamily

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.)

It allows your application, from JavaScript, to:

  1. Get browser based database access
  2. Get access to databases shipped with or created by your application
  3. Get GPS location information
  4. Get device acceleration information
  5. Show and use native Date and Date/Time pickers
  6. Vibrate the device
  7. Record and playback audio
  8. Play system sounds such as the notification sound
  9. Use a prebuilt drag and drop framework to easily make any DOM object draggable
  10. 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.

An installer is included to add QuickConnectiPhone templates to both Xcode and Dashcode to speed your development. It will also install beta versions of QuickConnectMac and QuickConnectPHP as well as file templates for JavaScript and PHP files.

QuickConnectMac allows you to write Mac applications using the same JavaScript framework that you use for iPhone applications. You can use this instead of Adobe Air. Write your application once and compile it for both iPhone and Mac.

The QuickConnectFamily image  Copyright Lee Barney 2008.  All rights reserved.

December 12, 2008

QuickConnectiPhone 1.1

Posted in Uncategorized tagged , , , , , , , , , , , , , , , , , , , , , , , , , at 4:19 am by tetontech

With the 1.0 release imminent it is now time to start considering what will be available in the 1.1 version. Here are some ideas. What is your opinion?

Current 1.0 feature list available from within JavaScript:

1 – Browser based database access
2 – Access to Objective-C based databases
3 – GPS location information
4 – acceleration information
5 – vibration
6 – playing system sounds
7 – recording and playing audio
8 – access to Date and Data/Time pickers
10 – embedded Google maps
11 – JavaScript drag and drop
12 – JavaScript gesture handling for resizing and rotation

1.1 Possible features available from within JavaScript:
1 – Bonjour networking data transfer
2 – data transfer via the connection cable
3 – Contact finding and addition
4 – Expanded Google maps (additional information available on selection of the pin short description)
5 – Calendar access and creation
6 – generalization of the record/play feature

Bonjour networking from within JavaScript on the iPhone

Posted in Uncategorized tagged , , , , at 4:08 am by tetontech

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.

This will be a wonderful addition to the framework. It is planned to be in version 1.1 and will also include the ability to do data transfer to and from your device via the cable. All of this from within JavaScript.

SQLite browser database in Google’s Android phone

Posted in Uncategorized tagged , , , , , at 4:01 am by tetontech

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.

I have ported the calls to from JavaScript to the Java accessible SQLite database however for the upcoming QuickConnectAndroid. At least it will have half of the database functionality of the iPhone.

December 7, 2008

QuickConnect Twitter and Google groups

Posted in Uncategorized at 3:16 am by tetontech

To aid you in developing your QuickConnect iPhone and other types of apps a Google group has been created.

http://groups.google.com/group/quickconnectiPhone

A twitter has also been created for quick and easy postings/questions/answers.

http://twitter.com/quickconnect

I hope this helps you in doing your development.

December 5, 2008

SQLite Access and Use

Posted in Uncategorized tagged , , , , , , , , , , , at 5:41 pm by tetontech

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).
The next easiest to use would be the Java classes in the Android phone and the most difficult to use would have to be the JavaScript functions that are part of the upcoming standard.

I say the JavaScript is the hardest since all of the calls are designed to be asynchronous and programmers are not used to interacting with a database in that fashion.

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.

So, all in all I would have to say that Apple and QT tie for first place. Google Android is a very distant second, and the JavaScript W3 standard implementation is in third place.

%d bloggers like this: