summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/control11
-rw-r--r--include/shortcut.h6
-rw-r--r--src/main.c97
-rw-r--r--test/Makefile4
-rw-r--r--test/application.c3
-rw-r--r--test/homescreen.c7
6 files changed, 107 insertions, 21 deletions
diff --git a/debian/control b/debian/control
index b8189ec..62da438 100644
--- a/debian/control
+++ b/debian/control
@@ -8,22 +8,21 @@ Standards-Version: 3.7.2
Package: libshortcut
Section: libs
Architecture: any
+Provides: libslp-shortcut-0
+Replaces: libslp-shortcut-0
+Conflicts: libslp-shortcut-0
Depends: ${shlibs:Depends}, ${misc:Depends}, libglib2.0-0, libdlog-0
Description: Shortcut service supporting library (shared object)
Package: libshortcut-dev
Section: libs
Architecture: any
-Depends: libshortcut-0 (= ${Source-Version})
+Depends: libshortcut (= ${Source-Version})
Description: Shortcut (Add to home) service supporting library (development)
-XB-Generate-Docs: yes
Package: libshortcut-dbg
Section: debug
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libshortcut-0 (= ${Source-Version})
+Depends: ${misc:Depends}, libshortcut (= ${Source-Version})
Description: Shortcut service supporting library (unstripped)
-
-
-
diff --git a/include/shortcut.h b/include/shortcut.h
index 7856e72..5a53029 100644
--- a/include/shortcut.h
+++ b/include/shortcut.h
@@ -53,7 +53,7 @@ extern "C" {
* @post None
* @remarks None
*/
-typedef int (*request_cb_t)(const char *pkgname, const char *name, int type, const char *content_info, const char *icon, int pid, void *data);
+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);
/**
* @brief This function prototype is used to define for receiving the result of add_to_home.
@@ -79,7 +79,7 @@ typedef int (*result_cb_t)(int ret, int pid, void *data);
enum {
SHORTCUT_PACKAGE = 0x0, /**< Launch the package using given pakcage name. */
SHORTCUT_DATA = 0x01, /**< Launch the related package with given data(content_info). */
- SHORTCUT_FILE = 0x02, /** < Launch the related package with given filename(content_info). */
+ SHORTCUT_FILE = 0x02, /**< Launch the related package with given filename(content_info). */
};
/**
@@ -211,6 +211,8 @@ extern int shortcut_set_request_cb(request_cb_t request_cb, void *data);
*/
extern int shortcut_add_to_home(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_to_home_with_period(const char *pkgname, const char *name, int type, const char *content, const char *icon, double period, result_cb_t result_cb, void *data);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/main.c b/src/main.c
index 86d6294..01d22a3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,7 +32,8 @@
#define EAPI __attribute__((visibility("default")))
-
+#define LIVEBOX_FLAG 0x0100
+#define TYPE_MASK 0x000F
extern int errno;
@@ -153,6 +154,7 @@ gboolean do_reply_service(int conn_fd, struct connection_state *state)
char *name;
char *exec;
char *icon;
+ double period;
if (state->packet.head.data.req.field_size.pkgname)
pkgname = state->payload;
@@ -179,20 +181,33 @@ gboolean do_reply_service(int conn_fd, struct connection_state *state)
icon = NULL;
}
- LOGD("Pkgname: [%s] Type: [%x], Name: [%s], Exec: [%s], Icon: [%s]\n",
+ if (state->packet.head.data.req.shortcut_type & LIVEBOX_FLAG) {
+ char *tmp;
+ tmp = state->payload + state->packet.head.data.req.field_size.pkgname;
+ tmp += state->packet.head.data.req.field_size.name;
+ tmp += state->packet.head.data.req.field_size.exec;
+ tmp += state->packet.head.data.req.field_size.icon;
+ memcpy(&period, tmp, sizeof(period));
+ } else {
+ period = -1.0f;
+ }
+
+ LOGD("Pkgname: [%s] Type: [%x], Name: [%s], Exec: [%s], Icon: [%s], Period: [%lf]\n",
pkgname,
state->packet.head.data.req.shortcut_type,
name,
exec,
- icon);
+ icon,
+ period);
ret = s_info.server_cb.request_cb(
pkgname,
name,
- state->packet.head.data.req.shortcut_type,
+ state->packet.head.data.req.shortcut_type & TYPE_MASK,
exec,
icon,
state->from_pid,
+ period,
s_info.server_cb.data);
}
@@ -706,7 +721,7 @@ EAPI int shortcut_set_request_cb(request_cb_t request_cb, void *data)
-EAPI int shortcut_add_to_home(const char *pkgname, const char *name, int type, const char *content_info, const char *icon, result_cb_t result_cb, void *data)
+EAPI int shortcut_add_to_home(const char *pkgname, const char *name, int type, const char *content, const char *icon, result_cb_t result_cb, void *data)
{
struct packet *packet;
int pkgname_len;
@@ -719,7 +734,7 @@ EAPI int shortcut_add_to_home(const char *pkgname, const char *name, int type, c
pkgname_len = pkgname ? strlen(pkgname) + 1 : 0;
name_len = name ? strlen(name) + 1 : 0;
- exec_len = content_info ? strlen(content_info) + 1 : 0;
+ exec_len = content ? strlen(content) + 1 : 0;
icon_len = icon ? strlen(icon) + 1 : 0;
packet_size = sizeof(*packet) + name_len + exec_len + icon_len + pkgname_len + 1;
@@ -745,9 +760,77 @@ EAPI int shortcut_add_to_home(const char *pkgname, const char *name, int type, c
payload += pkgname_len;
strncpy(payload, name, name_len);
payload += name_len;
- strncpy(payload, content_info, exec_len);
+ strncpy(payload, content, exec_len);
+ payload += exec_len;
+ strncpy(payload, icon, icon_len);
+
+ client_cb = malloc(sizeof(*client_cb));
+ if (!client_cb) {
+ LOGE("Heap: %s\n", strerror(errno));
+ free(packet);
+ return -ENOMEM;
+ }
+
+ client_cb->result_cb = result_cb;
+ client_cb->data = data;
+
+ if (init_client(client_cb, (const char*)packet, packet_size) < 0) {
+ LOGE("Failed to init client FD\n");
+ free(client_cb);
+ free(packet);
+ return -EFAULT;
+ }
+
+ free(packet);
+ return 0;
+}
+
+
+
+EAPI int shortcut_add_to_home_with_period(const char *pkgname, const char *name, int type, const char *content, const char *icon, double period, result_cb_t result_cb, void *data)
+{
+ struct packet *packet;
+ int pkgname_len;
+ int name_len;
+ int exec_len;
+ int icon_len;
+ int packet_size;
+ char *payload;
+ struct client_cb *client_cb;
+
+ pkgname_len = pkgname ? strlen(pkgname) + 1 : 0;
+ name_len = name ? strlen(name) + 1 : 0;
+ exec_len = content ? strlen(content) + 1 : 0;
+ icon_len = icon ? strlen(icon) + 1 : 0;
+
+ packet_size = sizeof(*packet) + name_len + exec_len + icon_len + pkgname_len + sizeof(period) + 1;
+
+ packet = malloc(packet_size);
+ if (!packet) {
+ LOGE("Heap: %s\n", strerror(errno));
+ return -ENOMEM;
+ }
+
+ packet->head.seq = s_info.seq++;
+ packet->head.type = PACKET_REQ;
+ packet->head.data.req.shortcut_type = LIVEBOX_FLAG | type;
+ packet->head.data.req.field_size.pkgname = pkgname_len;
+ packet->head.data.req.field_size.name = name_len;
+ packet->head.data.req.field_size.exec = exec_len;
+ packet->head.data.req.field_size.icon = icon_len;
+ packet->head.payload_size = sizeof(period) + pkgname_len + name_len + exec_len + icon_len + 1;
+
+ payload = packet->payload;
+
+ strncpy(payload, pkgname, pkgname_len);
+ payload += pkgname_len;
+ strncpy(payload, name, name_len);
+ payload += name_len;
+ strncpy(payload, content, exec_len);
payload += exec_len;
strncpy(payload, icon, icon_len);
+ payload += icon_len;
+ memcpy(payload, &period, sizeof(period));
client_cb = malloc(sizeof(*client_cb));
if (!client_cb) {
diff --git a/test/Makefile b/test/Makefile
index 45201b2..5dfe3d5 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,3 +1,3 @@
all:
- @gcc homescreen.c -o homescreen `pkg-config ecore elementary shortcut --cflags --libs`
- @gcc application.c -o application `pkg-config ecore elementary shortcut --cflags --libs`
+ @gcc homescreen.c -Wall -o homescreen `pkg-config ecore elementary shortcut --cflags --libs`
+ @gcc application.c -Wall -o application `pkg-config ecore elementary shortcut --cflags --libs`
diff --git a/test/application.c b/test/application.c
index 31c3fc9..3680419 100644
--- a/test/application.c
+++ b/test/application.c
@@ -32,6 +32,9 @@ static Eina_Bool shortcut_add_cb(void *data)
ret = shortcut_add_to_home("pkgname", "MyName", 0, "/usr/bin/true", "/opt/share/image/what.png", result_cb, NULL);
printf("Client: shortcut_add_to_home returns: %d\n", ret);
+ ret = shortcut_add_to_home_with_period("pkgname", "MyName", 0, "/usr/bin/true", "/opt/share/image/what.png", 1.0f, result_cb, NULL);
+ printf("Client: shortcut_add_to_home_with_period returns: %d\n", ret);
+
return ECORE_CALLBACK_RENEW;
}
diff --git a/test/homescreen.c b/test/homescreen.c
index fff75dc..a276af2 100644
--- a/test/homescreen.c
+++ b/test/homescreen.c
@@ -18,16 +18,15 @@
#include <Elementary.h>
#include <shortcut.h>
-int shortcut_request_cb(const char *pkgname, const char *name, int type, const char *exec, const char *icon, int pid, void *data)
+int shortcut_request_cb(const char *pkgname, const char *name, int type, const char *exec, const char *icon, int pid, double period, void *data)
{
- printf("SERVER: name: %s, type: %d, exec: %s, icon: %s, pid: %d, data: %p\n",
- name, type, exec, icon, pid, data);
+ printf("SERVER: name: %s, type: %d, exec: %s, icon: %s, pid: %d, data: %p, period: %lf\n",
+ name, type, exec, icon, pid, data, period);
return 0;
}
int elm_main(int argc, char *argv[])
{
- int ret;
shortcut_set_request_cb(shortcut_request_cb, NULL);
elm_run();