Using the synchronization options window

To use the options window (w_appname_sync_options for applications using remote SQL Anywhere databases or w_appname_sync_options for applications using remote UltraLite databases), code a menu item or button clicked event to call the gf_appname_configure_sync or the gf_appname_configure_ulsync function. This function creates an instance of the s_appname_sync_parms or s_appname_ulsync_parms structure and passes it to the options window.

The window’s Open event creates an instance of the nvo_appname_sync or nvo_appname_ulsync user object, and its ue_postopen event retrieves values from the registry to populate the text boxes in the window—unless you have chosen to override registry settings. The user can verify or modify options in the window and click either OK or Cancel.

If the user clicks OK, the gf_appname_configure_sync or gf_appname_configure_ulsync function calls gf_appname_sync or gf_appname_ulsync to launch synchronization using the MobiLink user name and password returned from the window. The user’s changes are also written to the registry.

The Close event of the window calls the wf_try_saving window function. If the user clicks OK, the wf_savesettings window function is launched. If the user clicks Cancel, no changes are made to the registry.

The options window has three pages: Subscriptions, MobiLink Server, and Settings. Although UltraLite databases do not have subscriptions, the information associating publications with a script version and a MobiLink user is the same type of information used to define subscriptions in SQL Anywhere databases.

Subscriptions page

When you used the MobiLink wizard, you selected one or more publications from the list of available publications. By default, the selected publications that display on the Subscriptions page cannot be edited at runtime for an application using a remote SQL Anywhere database. You can enable the Publications field for user entry at runtime by opening the options window in the Window painter, selecting the Publications text box, and clicking the Enabled check box in the Properties view.

Each remote user can supply a MobiLink synchronization user name on the Subscriptions page. For remote SQL Anywhere databases, the name must be associated in a subscription with the publications displayed on the page. If the application is always used by the same MobiLink user, this information never needs to be supplied again. The name is saved in the registry and used by default every time synchronization is launched from the application on this device.

If the user checks the Remember Password check box, the password is encrypted and saved in the registry. The uf_encrypt_pw and uf_decrypt_pw functions use a simple algorithm to ensure that the password does not display without encryption in the registry. You can replace this algorithm with a more sophisticated encryption technique.

MobiLink Server page

When you create a subscription, you specify a protocol, host, port, and other connection options. For ease of testing, the default protocol is TCP/IP and the default host is localhost. The default port is 2439 for TCP/IP, 80 for HTTP, and 443 for HTTPS.

You might need to change these defaults when you are testing, and your users might need to change them when your application is in use if the server is moved to another host or the port changes. For remote UltraLite database connections, the application user can enter additional parameters in the Additional text box in the format: keyword1=value1[;keywordN=valueN], where keyword is the parameter name and value is the parameter value. For remote SQL Anywhere databases, additional and extended parameters for the MobiLink server can be set by the user on the Settings page.

If the user does not make any changes to the MobiLink Server page of the options window, the synchronization process uses the values you entered in the wizard, if any. For remote SQL Anywhere databases, if you did not enter values in the wizard, dbmlsync uses the values in the subscription.

For more information about subscriptions, see “Adding subscriptions for remote SQL Anywhere databases”.

Settings page

For remote SQL Anywhere databases The Settings page displays the file DSN, logging options, and any other dbmlsync options you specified in the wizard. It also shows the three display options available to the user. This page lets the user change any of these options.

NoteExtended options Extended options are added to the dbmlsync command line with the -e switch. You do not need to type the -e switch in the text box.

For remote UltraLite databases The Settings page lets the user choose to display the generated status window, to send column names (for automatic generation of synchronization scripts), and to add or change authentication parameters.

Modifying generated objects

If you want to give or restrict user access to synchronization options available in the options window, modify the window at design time or use it as a template for your own options window. At a minimum, you probably need to provide a way for each user to enter a MobiLink user name and password.

If you want the user to be able to save options without launching a synchronization, you could comment out the lines in gf_appname_configure_sync or gf_appname_configure_ulsync that call the global synchronization function (gf_appname_sync or gf_appname_ulsync), or add a third button called Save Only that contains the same code as the OK button, but returns a non-zero value.