Using the synchronization options window

To use the w_appname_sync_options window in your application, code a menu item or button clicked event to call the gf_appname_configure_sync function. This function creates an instance of the s_appname_sync_parms structure and passes it to the options window.

The window’s Open event creates an instance of the nvo_appname_sync 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 function calls gf_appname_sync to launch synchronization using the MobiLink and remote database user names and passwords that are 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 four pages: Subscriptions, Connection, MobiLink Server, and Settings.

Subscriptions page

When you used the MobiLink wizard, you selected one or more publications from the list of available publications. The selected publications display on the Subscriptions page, but cannot be edited at runtime.

Each remote user can supply a MobiLink synchronization user name on this page. 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.

Connection page

Remote users can supply a DSN file name on this page to pass all the arguments needed to connect to a remote database.

If a DSN file is not used, or if the DSN file does not include a user name and password, each remote user can supply a remote database user name on the Connection page of the options window. The name is saved in the registry and used by default every time synchronization is launched from the application on this device.

Users can also include additional connection string arguments for the remote database by entering that information in the Additional text box on the Connection page. The following syntax should be used for additional parameters and values:

param1=value1;param2=value2;paramN=valueN

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

If the user does not make any changes on this page, dbmlsync uses the values you entered in the wizard, if any. If you did not enter values in the wizard, dbmlsync uses the values in the subscription.

For more information about subscriptions, see “Adding subscriptions”.

Settings page

The Settings page displays 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.

Modifying generated objects

If you want to give the user access to some dbmlsync options available in the options window, but not all of them, modify the window to suit your needs 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 and a remote database user name and password.

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