/* * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef __SHORTCUT_DOC_H__ #define __SHORTCUT_DOC_H__ /** * @defgroup SHORTCUT_MODULE Shortcut * @brief To enhance the Add to home feature. Two types of API sets are supported. * - One for the homescreen developers. * - The other for the application developers who should implement the Add to home feature. * @ingroup CAPI_APPLICATION_FRAMEWORK * @section SHORTCUT_MODULE_HEADER Required Header * \#include * @section SHORTCUT_MODULE_OVERVIEW Overview

1. Shortcut

Tizen is supporting the "add shortcut or add to home" for various applications. Developers may use the shortcut library (libshortcut) to implement features like sending (applications) and receiving (possibly home screen) shortcuts. If home screen implements the shortcut service using the library, the applications are good to go for adding their shortcuts to the home screen(, and vice versa.)

2. How to add a new shortcut to the home screen

2.1 Add to home (From the app to home)

The following are two separate APIs to support the "add to home" feature. \code typedef int (*result_cb_t)(int ret, int pid, void *data) extern int shortcut_add_shortcut(const char *pkgname, const char *name, int type, const char *content_info, const char *icon, result_cb_t result_cb, void *data) extern int shortcut_add_dynamicbox(const char *pkgname, const char *name, int type, const char *content, const char *icon, double period, result_cb_t result_cb, void *data) \endcode Currently, our home screen can contain two different types of contents (that are pure shortcuts and dynamicboxes). To add a pure shortcut i.e., simply for launching an app, developers can use the "shortcut_add_shortcut" API to deliver their shortcuts to a home screen. If your application supports our dynamicbox service and implements a dynamicbox type shortcut, then you can use the "shortcut_add_dynamicbox" API to have a home screen add the dynamicbox on its screen.
ParametersComment
pkgnamePackage name
nameApplication name which will be displayed on the screen
typeBasically it describes launching options whether to use a package name or URI. LAUNCH_BY_PACKAGE or LAUNCH_BY_URI
content Application data used for creating a pure shortcut or creating a dynamicbox Shortcut 1. If the type is Launch by package: None 2. If the type is Launch by URI: Put the URI in the content Dynamicbox: any data necessary to create a dynamicbox. Basically, it will be passed to the dynamicbox plug-in's create function.
iconAbsolute path to the icon file, If you set this to "NULL", the home screen will use the deafult icon file (but it is depends on the homescreen implementations)
period<Only for dynamicbox> Update period. The period must be greater than 0.0f
result_cbResult callback. The callback will be called after a shortcut or dynamicbox has been added. Don't forget to check the return value.
dataCallback data

2.1.1 Supported types

shortcut.h Enumeration values for type of shortcuts

2.2 Add shortcut (Home screen retrieves shortcuts from the app)

"Add shortcut " service enables home screen to retrieve all shortcuts that applications promised to support and request an app to send their shortcuts to home directly, as opposed to "add to home". It is initiated by the home screen as opposed to "add to home" which is initiated by an application.The "Add shortcut" service enables the home screen to retrieve all shortcuts that applications promised to support and request an app to send their shortcuts to home directly, as opposed to "add to home". It is initiated by the home screen as opposed to "add to home" which is initiated by an application.

2.2.1 Build the shortcut list DB

\image html BuildShortcutList.png To recognize how many and what kinds of shortcuts have been registered, each application who wants to support the "add shortcut" service needs to install the XML file that defines "shortcut" information. The following table describes the format and information necessary to define the shortcuts application can support. Then, the information will be shown and used in home screen when a user selects "add shortcut" service.
Syntax of the shortcut manifest file
\code ... /opt/share/icons/default/small/com.samsung.myapp-shortcut.png ... /opt/share/icons/default/small/com.samsung.myapp2.png ... \endcode
Install this XML file to /opt/share/packages/YOUR_PKGNAME.xml (Note: After manifest has been applied to the binary, simply copy the content to your manifest file.) The shortcut listing application will list up these items on its screen and each item will be displayed using the string in the label field. When selected, it will launch the selected app using app service with "appid" and a bundle holding data in the pair of extra_key and extra-data fields. Obviously, icon will be used to display visual information for given shortcut type.(that said the icon could be other than the application's default icon)

2.2.2 Jump to the APP

\image html JumpToApp.png The shortcut listing application will launch your application using app-svc with package name and param attributes. It will use the pkgname and param attrbute to launch your application. The shortcut list view will launch your "[App] Shortcut list" using the following code. When your app is launched, the app should send a selected item as a shortcut or dynamicbox to the home screen using "shortcut_add" series functions mentioned above.

2.2.3 What each app has to do

You can implement your shortcut list view using App or UG. Who is going to handle the shortcut In your shortcut list view, you just call the "shortcut_add_shortcut" or "shortcut_add_dynamicbox" which are described in the section 2.1

2.2.3.1 Handled by App

\image html ShortcutApp.png When your application is launched by the shortcut list application (displayed on the left most of above figure). Your application should go back to the normal view when you receive the PAUSE event. If you didn't change the view of your application, the user will see this shortcut list view again even if the user launches your application from the app-tray(or homescreen). So you have to change the view from the shortcut list to the normal(or previous) view when you get the PAUSE event.

2.2.3.2 Handled by UG

\image html ShortcutUG.png In this case, the Shortcut List application will launch your UG as a process. When you receive PAUSE event, or need to change to other view (not in the same UG), you should destroy current UG. If you didn't destroy it, it will be reside on the process list. and it will not be destroyed automatically. Currently, the UG container process only supports multiple instance for a process. So if the user tries to add a new shortcut again from the shortcut list application, your UG will be launched again if you didn't terminate previous UG process (when you got PAUSE event).

3. What the home screen should do

\code typedef int (*request_cb_t)(const char *pkgname, const char *name, int type, const char *content_info, const char *icon, int pid, double period, void *data) extern int shortcut_set_request_cb(request_cb_t request_cb, void *data) \endcode
ParameterComment
pkgnamePackage name to be added
nameApplication name to be displayed on the screen
typeLAUNCH_BY_PACKAGE or LAUNCH_BY_URI
content_infoUsed for the dynamicbox, or homescreen by itself if it required.
iconAbsolute path of the icon file. (If it is not exists, the homescreen can use the deafult icon file)
pidReuquestor's Process ID
periodUpdate period only for the dynamicbox
dataCallback data

4. To list up shortcuts registered in the device

shortcut-list viewer will launch your app by this way
\code int shortcut_get_list(const char *pkgname, int (*cb)(const char *pkgname, const char *icon, const char *name, const char *extra_key, const char *extra_data, void *data), void *data) \endcode
If you specified the "pkgname", this API will only gather the given Package's shortcut list. If you set is to NULL, this API will gathering all shortcuts. Every shortcut item will be passed via "cb" callback function. so it will be invoked N times if the number of registered shortcut item is N. pkgname and name and param is described in the XML file of each application package. It will returns the number of shortcut items, or return <0 as an error value. -EIO : failed to access the shortcut list DB > 0 : Number of shortcut items (count of callback function calling) * */ #endif /* __SHORTCUT_DOC_H__ */