Tizen Native API
Functions | Typedefs
Shortcut
Application Framework

Functions

int shortcut_add_to_home (const char *name, shortcut_type type, const char *uri, const char *icon, int allow_duplicate, result_cb_t result_cb, void *data)
 Supports the add_to_home feature, should invoke this.

Typedefs

typedef int(* result_cb_t )(int ret, void *data)
 Called to receive the result of shortcut_add_to_home().
typedef enum _shortcut_type shortcut_type
 Enumeration for shortcut types.

To enhance the Add to home feature.

Required Header

#include <shortcut_manager.h>

Overview

It provides function of creating shortcut. Developers can use the "shortcut_add_to_home" API to create their shortcut to a home screen.


Typedef Documentation

typedef int(* result_cb_t)(int ret, void *data)

Called to receive the result of shortcut_add_to_home().

Since :
2.3
Parameters:
[in]retThe result value, it could be 0 if it succeeds to add a shortcut, otherwise it returns an errno
[in]dataThe callback data
Returns:
int 0 if there is no error, otherwise errno
See also:
shortcut_add_to_home()

Enumeration for shortcut types.

Basically, two types of shortcuts are defined. Every homescreen developer should support these types of shortcuts. Or return a proper errno to figure out why the application failed to add a shortcut. LAUNCH_BY_APP is used for adding a package itself as a shortcut. LAUNCH_BY_URI is used for adding a shortcut for "uri" data.

Since :
2.3

Enumeration Type Documentation

Enumeration for shortcut types.

Basically, two types of shortcuts are defined. Every homescreen developer should support these types of shortcuts. Or return a proper errno to figure out why the application failed to add a shortcut. LAUNCH_BY_APP is used for adding a package itself as a shortcut. LAUNCH_BY_URI is used for adding a shortcut for "uri" data.

Since :
2.3
Enumerator:
LAUNCH_BY_APP 

Use these Launch the application itself

LAUNCH_BY_URI 

Launch the application with the given data(URI)

Enumeration for values of shortcut response types.

Since :
2.3
Enumerator:
SHORTCUT_ERROR_NONE 

Successfully handled

SHORTCUT_ERROR_INVALID_PARAMETER 

Shortcut request is not valid, invalid parameter or invalid argument value

SHORTCUT_ERROR_OUT_OF_MEMORY 

Memory is not enough to handle a new request

SHORTCUT_ERROR_IO_ERROR 

Unable to access the file or DB. Check your resource files

SHORTCUT_ERROR_PERMISSION_DENIED 

Has no permission to add a shortcut

SHORTCUT_ERROR_NOT_SUPPORTED 

Not supported shortcut

SHORTCUT_ERROR_RESOURCE_BUSY 

Receiver is busy, try again later

SHORTCUT_ERROR_NO_SPACE 

There is no space to add a new shortcut

SHORTCUT_ERROR_EXIST 

Shortcut is already added

SHORTCUT_ERROR_FAULT 

Failed to add a shortcut. Unrecoverable error

SHORTCUT_ERROR_COMM 

Connection is not established. or there is a problem in the communication


Function Documentation

int shortcut_add_to_home ( const char *  name,
shortcut_type  type,
const char *  uri,
const char *  icon,
int  allow_duplicate,
result_cb_t  result_cb,
void *  data 
)

Supports the add_to_home feature, should invoke this.

Sync (or) Async: This is an asynchronous API.

Since :
2.3
Privilege Level:
public
Privilege:
http://tizen.org/privilege/shortcut
Remarks:
Application must check the return value of this function.
Application must check the return status from the callback function.
Application should set the callback function to get the result of this request.
If a homescreen does not support this feature, you will get a proper error code.
Parameters:
[in]nameThe name of the created shortcut icon
[in]typeThe type of shortcuts
[in]uriThe specific information for delivering to the viewer for creating a shortcut
[in]iconThe absolute path of an icon file
[in]allow_duplicate1 if it accepts the duplicated shortcut, otherwise 0
[in]result_cbThe address of the callback function that is called when the result comes back from the viewer
[in]dataThe callback data that is used in the callback function
Returns:
0 on success, otherwise a negative error value
Return values:
SHORTCUT_ERROR_NONESuccessful
SHORTCUT_ERROR_INVALID_PARAMETERInvalid parameter
SHORTCUT_ERROR_OUT_OF_MEMORYOut of memory
SHORTCUT_ERROR_IO_ERRORI/O error
SHORTCUT_ERROR_PERMISSION_DENIEDPermission denied
SHORTCUT_ERROR_NOT_SUPPORTEDNot supported
SHORTCUT_ERROR_RESOURCE_BUSYDevice or resource busy
SHORTCUT_ERROR_NO_SPACENo space
SHORTCUT_ERROR_EXISTAlready exist
SHORTCUT_ERROR_FAULTUnrecoverable error
SHORTCUT_ERROR_COMMConnection failed
Precondition:
You have to prepare the callback function.
Postcondition:
You have to check the return status from the callback function which is passed by the argument.
See also:
result_cb_t
Example
 #include <stdio.h>
 #include <shortcut_manager.h>

 static int result_cb(int ret, int pid, void *data)
 {
    if (ret < 0)
        printf("Failed to add a shortcut: %s\n", perror(ret));

    printf("Processed by the %d\n", pid);
    return 0;
 }

 static int app_create(void *data)
 {
    char* data_path = app_get_data_path();
    int path_len = strlen(data_path)+10;
    char * path = malloc(path_len);
    memset(path, 0, path_len);
    strncat(path, data_path, path_len);
    strncat(path, "Friend.jpg", path_len); 

    shortcut_add_to_home("With friends",
                    LAUNCH_BY_URI, "gallery:0000-0000",
                    path, 0, result_cb, NULL);
    free(path);

    return 0;
 }

 int main(int argc, char *argv[])
 {
    appcore....
 }

Except as noted, this content - excluding the Code Examples - is licensed under Creative Commons Attribution 3.0 and all of the Code Examples contained herein are licensed under BSD-3-Clause.
For details, see the Content License