From 5793b6a1ba1e76bf68046fb4fa84f07b2831773f Mon Sep 17 00:00:00 2001 From: Ickhee Woo Date: Wed, 23 Dec 2015 15:04:18 +0900 Subject: [PATCH] fixed guide and tutorial for consistency with modifications of tizen.org Change-Id: If5fd5d19de9c7a668081c7ebe49703da7c4456f5 Signed-off-by: Ickhee Woo --- .../html/native/account/sync_manager_n.htm | 18 ++-- .../native/account/sync_manager_tutorial_n.htm | 113 ++++++++------------- 2 files changed, 50 insertions(+), 81 deletions(-) diff --git a/org.tizen.guides/html/native/account/sync_manager_n.htm b/org.tizen.guides/html/native/account/sync_manager_n.htm index 13b4a05..2b56c28 100644 --- a/org.tizen.guides/html/native/account/sync_manager_n.htm +++ b/org.tizen.guides/html/native/account/sync_manager_n.htm @@ -62,11 +62,11 @@ Data changes on the device A subscribed callback function is invoked whenever a database change occurs for a registered capability. The data change listener notices the changes by using the Calendar, Contacts, and Media Content APIs. If there are any changes in the corresponding data, the sync manager notices the changes and schedules a sync job. -

Changing data in the Calendar database includes adding, updating, and deleting books, events, and todos. Changing data in the Contacts database includes adding, removing, and modifying contacts. Data change for the Calendar / Contacts capabilities are supported only on Tizen Mobile. The media content provides notifications for changes in media types, such as image, music, sound, and video.

+

Changing data in the Calendar database includes adding, updating, and deleting books, events, and todos. Changing data in the Contacts database includes adding, removing, and modifying contacts. The Media Content provides notifications for changes in media types, such as image, music, sound, and video.

Network availability - When a status change in the Wi-Fi or data network is detected, a sync job occurs. + When a status change in the Wi-Fi or data network is detected, behavior of sync operation is changed. On demand sync @@ -100,15 +100,15 @@ Sync job name const char* Yes - Sync job name for managing the jobs. + Sync job name for managing sync jobs.

The on-demand and periodic sync jobs can be managed by a user-defined name. If the sync_manager_add_periodic_sync_job() function is called again with same sync job name (where all details except the name and sync job ID are changed), the function does not add a new sync job but updates the existing job. This is mainly used to reset the periodic interval.

Sync capability const char* Yes - Capability for a data change sync job. -

A data change sync job can provide a notification whenever a corresponding data change occurs. If the sync_manager_add_data_change_sync_job() function is used with a capability, it is operated for the related capability only. In the case of using the calendar or contact capability, the respective http://tizen.org/privilege/calendar.read or http://tizen.org/privilege/contact.read privilege is required. Data change for the Calendar / Contacts capabilities are supported only on Tizen Mobile.

+ Capability for adding data change sync jobs. +

A data change sync job can provide a notification whenever a corresponding data change occurs. If the sync_manager_add_data_change_sync_job() function is used with a capability, it is operated for the related capability only. In the case of using the calendar or contact capability, the respective http://tizen.org/privilege/calendar.read or http://tizen.org/privilege/contact.read privilege is required.

The following capabilities are available:

 #define SYNC_SUPPORTS_CAPABILITY_CALENDAR "http://tizen.org/sync/capability/calendar"
@@ -122,7 +122,7 @@
                Sync period
                sync_period_e
                Yes
-       Interval for a periodic sync job.
+       Interval for adding periodic sync jobs.
 	   

If the interval is provided, the sync job is performed periodically. If you set the periodic interval to 30 minutes, a time interval is set as a power of 2 less than 30. This means that a time interval set to 16 minutes operates the sync job every 16 minutes while skipping the first notification (so the first is in 32 minutes). The same logic applies to other cases.

This variable provides a periodic sync job with an inexact time. Coupling various periodic sync jobs with an interval as a power of 2 prevents the device from waking up the service application too many times.

The sync_period_e enumerator defines the available period intervals.

@@ -131,7 +131,7 @@ Sync option sync_option_e Yes - Option for deciding the sync job behavior. + Option for deciding sync job behavior.

The behavior options can be used as an OR value. For example, the (SYNC_OPTION_EXPEDITED | SYNC_OPTION_NO_RETRY) expression is available, and means that the "Sync job is operated just once with priority".

The following options are available:

  • SYNC_OPTION_NONE: Sync job is operated normally
  • @@ -149,7 +149,7 @@ Sync job user data bundle* No - User data for a sync job. + User data for sync jobs.

    The data can contain additional information related to the registered sync jobs.

    @@ -179,7 +179,7 @@

    The Sync Adapter API allows you to:

      -
    • Register callbacks for notifications about the sync job start and cancellation.
    • +
    • Register callbacks for receiving notifications about the sync job start and cancellation.
    • Start a sync operation with an app control, so that the application's daemon needs not to stay awake.

      The Sync Adapter API allows you to use this mechanism without using the App Control API separately. In other words, when using the Sync Adapter API, you can use the App Control API indirectly.

    • diff --git a/org.tizen.tutorials/html/native/account/sync_manager_tutorial_n.htm b/org.tizen.tutorials/html/native/account/sync_manager_tutorial_n.htm index 3d24ed0..dc1bdfb 100644 --- a/org.tizen.tutorials/html/native/account/sync_manager_tutorial_n.htm +++ b/org.tizen.tutorials/html/native/account/sync_manager_tutorial_n.htm @@ -56,7 +56,7 @@
    • Initializing the Periodic Sync

      Add a periodic sync job with a recurring cycle.

    • Initializing the Data Change Sync -

      Add a data change sync job for receiving a notification whenever a specific database change occurs.

    • +

      Add a data change sync job for receiving notifications whenever a specific database change occurs.

    • Initializing the ForEach Sync

      Iterate all the registered sync jobs for managing them more efficiently.

    • Sync adapter @@ -112,33 +112,25 @@ int sync_job_id = -1;
    • Add an on-demand sync job:
      -result = sync_manager_on_demand_sync_job(account, sync_job_name, SYNC_OPTION_NONE, 
      -                                         sync_job_user_data, &sync_job_id);
      +result = sync_manager_on_demand_sync_job(account, sync_job_name, SYNC_OPTION_NONE, sync_job_user_data, &sync_job_id);
       

      This function can be used with various options, as shown in the following example. The SYNC_OPTION_NO_RETRY option means the sync job is not performed again when it fails. The SYNC_OPTION_EXPEDITED option means the other sync job is operated as soon as possible. The call with the OR structure lets the other sync job operate just once with priority.

      - +
      -result = sync_manager_on_demand_sync_job(account, sync_job_name2, SYNC_OPTION_NO_RETRY, 
      -                                         sync_job_user_data, &sync_job_id2);
      -result = sync_manager_on_demand_sync_job(account, sync_job_name3, SYNC_OPTION_EXPEDITED, 
      -                                         sync_job_user_data, &sync_job_id3);
      -result = sync_manager_on_demand_sync_job(account, sync_job_name4, 
      -                                         (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED), 
      -                                         sync_job_user_data, &sync_job_id4);
      +result = sync_manager_on_demand_sync_job(account, sync_job_name2, SYNC_OPTION_NO_RETRY, sync_job_user_data, &sync_job_id2);
      +result = sync_manager_on_demand_sync_job(account, sync_job_name3, SYNC_OPTION_EXPEDITED, sync_job_user_data, &sync_job_id3);
      +result = sync_manager_on_demand_sync_job(account, sync_job_name4, (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED), sync_job_user_data, &sync_job_id4);
       

      This function can also be called like in the following example, because the account handle and user data are not mandatory:

      -result = sync_manager_on_demand_sync_job(NULL, sync_job_name, SYNC_OPTION_NONE, 
      -                                         sync_job_user_data, &sync_job_id);
      -result = sync_manager_on_demand_sync_job(account, sync_job_name2, SYNC_OPTION_NO_RETRY, 
      -                                         NULL, &sync_job_id2);
      -result = sync_manager_on_demand_sync_job(NULL, sync_job_name3, SYNC_OPTION_EXPEDITED, 
      -                                         NULL, &sync_job_id3);
      +result = sync_manager_on_demand_sync_job(NULL, sync_job_name, SYNC_OPTION_NONE, sync_job_user_data, &sync_job_id);
      +result = sync_manager_on_demand_sync_job(account, sync_job_name2, SYNC_OPTION_NO_RETRY, NULL, &sync_job_id2);
      +result = sync_manager_on_demand_sync_job(NULL, sync_job_name3, SYNC_OPTION_EXPEDITED, NULL, &sync_job_id3);
       

      If the on-demand sync job addition process succeeds, the SYNC_ERROR_NONE value is returned.

    • -
    • When the on-demand sync is no longer needed, remove it with the sync_manager_remove_sync_job() function with its sync_job_id. If you want to stop using the account too, clean up the account handle. +
    • When the on-demand sync is no longer needed, remove it with the sync_manager_remove_sync_job() function with its sync_job_id. If you want to stop using the account too, clean up the account handle.

      At the end, unset the sync callbacks and release the resources with the sync_adapter_unset_callbacks() function.

       result = sync_manager_remove_sync_job(sync_job_id);
      @@ -156,7 +148,7 @@ sync_adapter_unset_callbacks();
       
    • - +

      Initializing the Periodic Sync

      To inform periodically a service application of the time to operate a sync job with its sync interval:

      @@ -206,44 +198,34 @@ int sync_job_id = -1;
    • Add a periodic sync job with an interval as 30 minutes.

      This function operates the sync job with the given period interval.

      -result = sync_manager_add_periodic_sync_job(account, sync_job_name, sync_period, SYNC_OPTION_NONE, 
      -                                            sync_job_user_data, &sync_job_id);
      +result = sync_manager_add_periodic_sync_job(account, sync_job_name, sync_period, SYNC_OPTION_NONE, sync_job_user_data, &sync_job_id);
       

      This function can be used with various options, as shown in the following example. The SYNC_OPTION_NO_RETRY option means a sync job is not performed again when it fails. The SYNC_OPTION_EXPEDITED option means another sync job is operated as soon as possible. The call with the OR structure lets the other sync job operate just once with priority.

      -result = sync_manager_add_periodic_sync_job(account, sync_job_name2, sync_period2, SYNC_OPTION_NO_RETRY, 
      -                                            sync_job_user_data, &sync_job_id2);
      -result = sync_manager_add_periodic_sync_job(account, sync_job_name3, sync_period3, SYNC_OPTION_EXPEDITED, 
      -                                            sync_job_user_data, &sync_job_id3);
      -result = sync_manager_add_periodic_sync_job(account, sync_job_name4, sync_period4, 
      -                                            (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED), 
      -                                            sync_job_user_data, &sync_job_id4);
      +result = sync_manager_add_periodic_sync_job(account, sync_job_name2, sync_period2, SYNC_OPTION_NO_RETRY, sync_job_user_data, &sync_job_id2);
      +result = sync_manager_add_periodic_sync_job(account, sync_job_name3, sync_period3, SYNC_OPTION_EXPEDITED, sync_job_user_data, &sync_job_id3);
      +result = sync_manager_add_periodic_sync_job(account, sync_job_name4, sync_period4, (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED), sync_job_user_data, &sync_job_id4);
       

      This function can also be called like in the following example, because the account handle and user data are not mandatory:

      -result = sync_manager_add_periodic_sync_job(NULL, sync_job_name, sync_period, SYNC_OPTION_NONE, 
      -                                            sync_job_user_data, &sync_job_id);
      -result = sync_manager_add_periodic_sync_job(account, sync_job_name2, sync_period2, SYNC_OPTION_NO_RETRY, 
      -                                            NULL, &sync_job_id2);
      -result = sync_manager_add_periodic_sync_job(NULL, sync_job_name3, sync_period3, SYNC_OPTION_EXPEDITED, 
      -                                            NULL, &sync_job_id3);
      +result = sync_manager_add_periodic_sync_job(NULL, sync_job_name, sync_period, SYNC_OPTION_NONE, sync_job_user_data, &sync_job_id);
      +result = sync_manager_add_periodic_sync_job(account, sync_job_name2, sync_period2, SYNC_OPTION_NO_RETRY, NULL, &sync_job_id2);
      +result = sync_manager_add_periodic_sync_job(NULL, sync_job_name3, sync_period3, SYNC_OPTION_EXPEDITED, NULL, &sync_job_id3);
       

      If the periodic sync job addition process succeeds, the SYNC_ERROR_NONE value is returned.

    • The sync_manager_add_periodic_sync_job() function can renew a registered periodic sync job by using the same sync_job_name as before:
      -result = sync_manager_add_periodic_sync_job(account, sync_job_name, sync_period, SYNC_OPTION_NONE, 
      -                                            sync_job_user_data, &sync_job_id);
      -result = sync_manager_add_periodic_sync_job(account, sync_job_name, sync_period2, SYNC_OPTION_EXPEDITED, 
      -                                            sync_job_user_data2, &sync_job_id);
      +result = sync_manager_add_periodic_sync_job(account, sync_job_name, sync_period, SYNC_OPTION_NONE, sync_job_user_data, &sync_job_id);
      +result = sync_manager_add_periodic_sync_job(account, sync_job_name, sync_period2, SYNC_OPTION_EXPEDITED, sync_job_user_data2, &sync_job_id);
       

      All the function parameters can be reset except sync_job_name and sync_job_id, which are used to manage a specific sync job.

    • -
    • When the periodic sync is no longer needed, remove it with the sync_manager_remove_sync_job() function with its sync_job_id. If you want to stop using the account too, clean up the account handle. +
    • When the periodic sync is no longer needed, remove it with the sync_manager_remove_sync_job() function with its sync_job_id. If you want to stop using the account too, clean up the account handle.

      At the end, unset the sync callbacks and release the resources with the sync_adapter_unset_callbacks() function.

      - +
       result = sync_manager_remove_sync_job(sync_job_id);
       
      @@ -313,44 +295,34 @@ int sync_job_id = -1;
       
    • Add a data change sync job for the calendar capability.

      The sync_manager_add_data_change_sync_job() function operates a sync job only for a registered capability.

      -result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar, SYNC_OPTION_NONE, 
      -                                               sync_job_user_data, &sync_job_id);
      +result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar, SYNC_OPTION_NONE, sync_job_user_data, &sync_job_id);
       

      This function can be used with various options, as shown in the following example. The SYNC_OPTION_NO_RETRY option means a sync job is not performed again when it fails. The SYNC_OPTION_EXPEDITED option means another sync job is operated as soon as possible. The call with the OR structure lets the other sync job operate just once with priority.

      -result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar, SYNC_OPTION_NO_RETRY, 
      -                                               sync_job_user_data, &sync_job_id2);
      -result = sync_manager_add_data_change_sync_job(account, sync_capability_contact, SYNC_OPTION_EXPEDITED, 
      -                                               sync_job_user_data, &sync_job_id3);
      -result = sync_manager_add_data_change_sync_job(account, sync_capability_image, 
      -                                               (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED), 
      -                                               sync_job_user_data, &sync_job_id4);
      +result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar, SYNC_OPTION_NO_RETRY, sync_job_user_data, &sync_job_id2);
      +result = sync_manager_add_data_change_sync_job(account, sync_capability_contact, SYNC_OPTION_EXPEDITED, sync_job_user_data, &sync_job_id3);
      +result = sync_manager_add_data_change_sync_job(account, sync_capability_image, (SYNC_OPTION_NO_RETRY | SYNC_OPTION_EXPEDITED), sync_job_user_data, &sync_job_id4);
       

      This function can also be called like in the following example, because the account handle and user data are not mandatory:

      -result = sync_manager_add_data_change_sync_job(NULL, sync_capability_music, SYNC_OPTION_NONE, 
      -                                               sync_job_user_data, &sync_job_id);
      -result = sync_manager_add_data_change_sync_job(account, sync_capability_sound, SYNC_OPTION_NO_RETRY, 
      -                                               NULL, &sync_job_id2);
      -result = sync_manager_add_data_change_sync_job(NULL, sync_capability_video, SYNC_OPTION_EXPEDITED, 
      -                                               NULL, &sync_job_id3);
      +result = sync_manager_add_data_change_sync_job(NULL, sync_capability_music, SYNC_OPTION_NONE, sync_job_user_data, &sync_job_id);
      +result = sync_manager_add_data_change_sync_job(account, sync_capability_sound, SYNC_OPTION_NO_RETRY, NULL, &sync_job_id2);
      +result = sync_manager_add_data_change_sync_job(NULL, sync_capability_video, SYNC_OPTION_EXPEDITED, NULL, &sync_job_id3);
       

      If the data change sync job addition process succeeds, the SYNC_ERROR_NONE value is returned.

    • The sync_manager_add_data_change_sync_job() function can renew a registered data change sync job by using the same sync_capability as before:
      -result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar, SYNC_OPTION_NONE, 
      -                                               sync_job_user_data, &sync_job_id);
      -result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar, SYNC_OPTION_EXPEDITED, 
      -                                               sync_job_user_data2, &sync_job_id);
      +result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar, SYNC_OPTION_NONE, sync_job_user_data, &sync_job_id);
      +result = sync_manager_add_data_change_sync_job(account, sync_capability_calendar, SYNC_OPTION_EXPEDITED, sync_job_user_data2, &sync_job_id);
       

      All the function parameters can be reset except sync_capability and sync_job_id, which are used to manage a specific sync job.

    • -
    • When the data change sync is no longer needed, remove it with the sync_manager_remove_sync_job() function with its sync_job_id. If you want to stop using the account too, clean up the account handle. +
    • When the data change sync is no longer needed, remove it with the sync_manager_remove_sync_job() function with its sync_job_id. If you want to stop using the account too, clean up the account handle.

      At the end, unset the sync callbacks and release the resources with the sync_adapter_unset_callbacks() function.

      @@ -390,11 +362,10 @@ result = sync_manager_foreach_sync_job(sync_job_cb, NULL);
       
       
    • Define the sync_job_cb() callback, which is invoked separately for every registered sync job. In the callback, the sync jobs are verified with a corresponding data.
      -bool 
      -sync_job_cb(account_h account, const char *sync_job_name, const char *sync_capability, 
      -            int sync_job_id, bundle *sync_job_user_data, void *user_data)
      +bool
      +sync_job_cb(account_h account, const char *sync_job_name, const char *sync_capability, int sync_job_id, bundle *sync_job_user_data, void *user_data)
       {
      -   // Verify the registered sync jobs
      +   // Verify registered sync jobs
       }
       
    • @@ -423,18 +394,16 @@ result = sync_adapter_set_callbacks(on_start_cb, on_cancel_cb);
    • When the on_start_cb() callback is invoked, the predefined data sync process is performed inside the callback function. The on_cancel_cb() callback works in a similar way and cancels the data sync process.
      -bool 
      -on_start_cb(account_h account, const char *sync_job_name, 
      -            const char *sync_capability, bundle *sync_job_user_data)
      +bool
      +on_start_cb(account_h account, const char *sync_job_name, const char *sync_capability, bundle *sync_job_user_data)
       {
      -   // Start the data sync process
      +   // Start data sync process
       }
       
      -void 
      -on_cancel_cb(account_h account, const char *sync_job_name, 
      -             const char *sync_capability, bundle *sync_job_user_data)
      +void
      +on_cancel_cb(account_h account, const char *sync_job_name, const char *sync_capability, bundle *sync_job_user_data)
       {
      -   // Cancel the data sync process
      +   // Cancel data sync process
       }
       
    • -- 2.7.4