src/custombar.cpp
src/deletebar.cpp
src/engine.cpp
+ src/engine/src/Entity.cpp
+ src/engine/src/EngineBarItem.cpp
+ src/engine/src/EngineUBarItem.cpp
+ src/engine/src/EngineDBarItem.cpp
+ src/engine/src/EngineDBarItemContent.cpp
src/bus.cpp
src/client_bus.cpp
src/Parcel.cpp
#include <stdbool.h>
+#include <gio/gio.h>
#include <cp_config.h>
+#include "Parcel.h"
class CBaseBus {
+++ /dev/null
-/*
- * Copyright (c) 2014 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 __ENGINE_H__
-#define __ENGINE_H__
-
-#include <Eina.h>
-#include <stdbool.h>
-
-struct engine;
-struct engine_bar_item;
-struct engine_ubar_item;
-struct engine_dbar_item;
-struct engine_dbar_item_content;
-
-enum engine_dbar_item_style {
- ENGINE_DBAR_ITEM_STYLE_CONTENT,
- ENGINE_DBAR_ITEM_STYLE_LABEL,
- ENGINE_DBAR_ITEM_STYLE_ALBUM,
- ENGINE_DBAR_ITEM_STYLE_MAX
-};
-
-enum engine_dbar_content_type {
- ENGINE_DBAR_CONTENT_TYPE_IMAGE,
- ENGINE_DBAR_CONTENT_TYPE_VIDEO,
- ENGINE_DBAR_CONTENT_TYPE_MUSIC,
- ENGINE_DBAR_CONTENT_TYPE_BROADCAST,
- ENGINE_DBAR_CONTENT_TYPE_APP,
- ENGINE_DBAR_CONTENT_TYPE_SOURCE,
- ENGINE_DBAR_CONTENT_TYPE_NOTIFICATION_NOTI,
- ENGINE_DBAR_CONTENT_TYPE_NOTIFICATION_ONGOING,
- ENGINE_DBAR_CONTENT_TYPE_HISTORY,
- ENGINE_DBAR_CONTENT_TYPE_MAX
-};
-
-
-struct engine *engine_init(void);
-void engine_fini(struct engine *eng);
-int engine_get_user_info(struct engine *eng, const char **name,
- const char **thumb_bg, const char **thumb);
-
-const Eina_List *engine_get_bar_items(struct engine *eng);
-const Eina_List *engine_get_ubar_items(struct engine *eng);
-const Eina_List *engine_get_dbar_items(struct engine_bar_item *it);
-
-/* bar */
-const char *engine_bar_item_get_name(struct engine_bar_item *it);
-const char *engine_bar_item_get_icon(struct engine_bar_item *it);
-const char *engine_bar_item_get_icon_focus(struct engine_bar_item *it);
-const char *engine_bar_item_get_dbus_path(struct engine_bar_item *it);
-const char *engine_bar_item_get_noctnt_title(struct engine_bar_item *it);
-const char *engine_bar_item_get_noctnt_desc(struct engine_bar_item *it);
-const char *engine_bar_item_get_in(struct engine_bar_item *it);
-const char *engine_bar_item_get_svcid(struct engine_bar_item *it);
-const char *engine_bar_item_get_bus_name(struct engine_bar_item *it);
-const char *engine_bar_item_get_object_path(struct engine_bar_item *it);
-int engine_bar_item_get_color(struct engine_bar_item *it,
- int *r, int *g, int *b);
-int engine_bar_item_get_content_column(struct engine_bar_item *it,
- int *content_column);
-int engine_bar_item_launch(struct engine_bar_item *it);
-int engine_bar_item_del_pin(struct engine *eng, struct engine_bar_item *it);
-int engine_bar_item_get_pin_count(void);
-int engine_bar_item_swap_pin(struct engine *eng, struct engine_bar_item *it1,
- struct engine_bar_item *it2);
-Eina_Bool engine_bar_item_get_is_pinned(struct engine_bar_item *it);
-void engine_bar_item_set_update_cb(struct engine_bar_item *it,
- void (*update_cb)(struct engine_bar_item *it, void *data),
- void *data);
-void engine_bar_item_set_pin_update_cb(struct engine *eng,
- void (*update_cb)(void *data, bool focus),
- void *data);
-
-/* ubar */
-int engine_ubar_item_get_info(struct engine_ubar_item *it, const char **name,
- const char **thumb_bg, const char **thumb, int *age);
-bool engine_ubar_item_is_password(struct engine_ubar_item *it,
- const char *password);
-bool engine_ubar_item_delete(struct engine *eng, struct engine_ubar_item *it,
- const char *password);
-bool engine_ubar_item_add(struct engine *eng, const char *name,
- const char *password, const char *icon);
-bool engine_ubar_item_update(struct engine *eng, struct engine_ubar_item *it,
- const char *icon, const char *password);
-bool engine_ubar_item_change_user(struct engine *eng,
- struct engine_ubar_item *it, const char *password);
-bool engine_ubar_item_get_privilege(struct engine *eng);
-
-
-/* dbar */
-enum engine_dbar_item_style engine_dbar_item_get_style(
- struct engine_dbar_item *it);
-enum engine_dbar_content_type engine_dbar_item_get_content_type(
- struct engine_dbar_item_content *ctnt);
-const Eina_List *engine_dbar_item_get_contents(struct engine_dbar_item *it);
-const char *engine_dbar_item_get_name(struct engine_dbar_item *it);
-const char *engine_dbar_item_get_in(struct engine_dbar_item *it);
-const char *engine_dbar_item_get_content_subtitle(
- struct engine_dbar_item_content *ctnt);
-const char *engine_dbar_item_get_content_description(
- struct engine_dbar_item_content *ctnt);
-const char *engine_dbar_item_get_content_detail(
- struct engine_dbar_item_content *ctnt);
-const char *engine_dbar_item_get_content_thumbnail(
- struct engine_dbar_item_content *ctnt);
-const char *engine_dbar_item_get_content_icon(
- struct engine_dbar_item_content *ctnt);
-int engine_dbar_item_get_color(struct engine_dbar_item *it,
- int *r, int *g, int *b);
-int engine_dbar_item_launch(struct engine_dbar_item *it);
-int engine_dbar_item_del(struct engine_dbar_item *it,
- enum engine_dbar_content_type type);
-int engine_dbar_item_del_all(enum engine_dbar_content_type type);
-
-#endif /* __ErGINE_H__ */
return false;
}
+ bool ret = false;
+
if (strcmp(BUS_METHOD_ADD_ALBUM, method) == 0) {
- t_EventAddAlbum(param);
+ ret = t_EventAddAlbum(param);
}
else if (strcmp(BUS_METHOD_ADD_LABEL, method) == 0) {
- t_EventAddLabel(param);
+ ret = t_EventAddLabel(param);
}
else if (strcmp(BUS_METHOD_ADD_CONTENT, method) == 0) {
- t_EventAddContent(param);
+ ret = t_EventAddContent(param);
}
else if (strcmp(BUS_METHOD_ADD_PIN, method) == 0) {
- t_EventAddPin(param);
+ ret = t_EventAddPin(param);
}
else if (strcmp(BUS_METHOD_DEL_CONTENT, method) == 0) {
- t_EventDelAllContent(param);
+ ret = t_EventDelAllContent(param);
}
else if (strcmp(BUS_METHOD_DEL_ALL, method) == 0) {
- t_EventDelAllContent(param);
+ ret = t_EventDelAllContent(param);
}
- return true;
+ return ret;
}
--- /dev/null
+/*
+ * Copyright (c) 2014 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 __BUS_H__
+#define __BUS_H__
+
+
+#include <stdbool.h>
+#include <gio/gio.h>
+#include <cp_config.h>
+#include "Parcel.h"
+
+class CBaseBus {
+private:
+ struct SBaseBus* m;
+
+private:
+ /**
+ * Invoked function to register callbacks in interface table if bus is acquired.
+ *
+ * @param connection The GDBusConnection to a message bus
+ * @param name The name tha is requested to be owned
+ * @param data The bus object
+ */
+ static void sm_CbHandlerBusAcquired(GDBusConnection *conn, const gchar *name,
+ gpointer data);
+ /**
+ * Invoked when bus name is acquired and calls bus ready callback function
+ * to emit the SIGNAL_REFRESH signal to daemons.
+ *
+ * @param connection The GDBusConnection on which to acquired the name
+ * @param name The name being owned
+ * @param data The bus object
+ */
+ static void sm_CbHandlerNameAcquired(GDBusConnection *conn, const char *name,
+ gpointer data);
+ /**
+ * Invoked when bus name lost and calls bus end callback function.
+ *
+ * @param conn The GDBusConnection on which to acquire the name or NULL
+ * if the connection was disconected
+ * @param name The name being owned
+ * @param data The bus object
+ */
+ static void sm_CbHandlerNameLost(GDBusConnection *conn, const char *name,
+ gpointer data);
+
+ /**
+ * Registers method and handler callback function.
+ *
+ * @param conn The GDBusConnection
+ * @param sender The unique bus name
+ * @param obj_path The object path that the method was invoked on
+ * @param if_name The D-Bus interface name the method was invoked on
+ * @param method The name of the method that was invoked
+ * @param param The message the remote caller would send
+ * @param iv The GDBusMethodInvocation object that can be used to return a value
+ * @param data The bus object
+ */
+ static void sm_CbMethodCall(GDBusConnection *conn,
+ const gchar *sender, const gchar *obj_path,
+ const gchar *if_name, const gchar *method,
+ GVariant *param, GDBusMethodInvocation *iv,
+ gpointer data);
+
+protected:
+ void t_OnBusAcquired(GDBusConnection *conn, const gchar *name);
+ void t_OnNameAcquired(GDBusConnection *conn, const char *name);
+ void t_OnNameLost(GDBusConnection *conn, const char *name);
+
+ virtual void t_OnReady(void);
+ virtual void t_OnEnd(void);
+
+public:
+ struct SCallback {
+ void *cookie;
+ void(*cbReady)(CBaseBus *bus, void *cookie);
+ void(*cbEnd)(CBaseBus *bus, void *cookie);
+ };
+
+protected:
+ virtual bool t_OnEvent(const char *method, GVariant *param) { return false; }
+
+private:
+ /**
+ * Initialize bus for sending the dynamic bar contents.
+ *
+ * Parses BUS_INTROSPECTION_XML data and creates bus.
+ *
+ * @param bus The bus object
+ * @return This function returns zero on success, or negative value
+ */
+ bool m_Create(void);
+ void m_Destroy(void);
+
+public:
+ CBaseBus() : m(0) {}
+ virtual ~CBaseBus() {}
+ bool FlagCreate(void) { return !!m; }
+
+ bool Create(const SCallback *callback);
+ virtual void Destroy(void);
+
+ bool SendSignal(const char *sig);
+};
+
+
+class CBus : public CBaseBus, public CParcel {
+public:
+ enum EActionOp {
+ ACTION_OP_LAUNCH_NONE,
+ ACTION_OP_LAUNCH_APP,
+ ACTION_OP_LAUNCH_SERVICE,
+ ACTION_OP_MAX
+ };
+
+ enum EContentType {
+ CONTENT_TYPE_IMAGE,
+ CONTENT_TPPE_VIDEO,
+ CONTENT_TYPE_MUSIC,
+ CONTENT_TYPE_BROADCAST,
+ CONTENT_TYPE_APP,
+ CONTENT_TYPE_SOURCE,
+ CONTENT_TYPE_NOTIFICATION_NOTI,
+ CONTENT_TYPE_NOTIFICATION_ONGOING,
+ CONTENT_TYPE_HISTORY,
+ CONTENT_TYPE_MAX
+ };
+
+ enum EPinType {
+ PIN_TYPE_CHANNEL,
+ PIN_TYPE_PACKAGE,
+ PIN_TYPE_MAX
+ };
+
+ #define BUS_DATA_ALBUM_CONTENT_MAX 6
+
+ struct SBase {
+ const char *svcid;
+ const char *title;
+ };
+
+ struct SLabel : public SBase {
+ EActionOp action;
+ const char *actor;
+ const char *args;
+ };
+
+ struct SContent : public SBase {
+ EContentType type;
+ const char *subtitle;
+ const char *description;
+ const char *detail;
+ const char *thumbnail;
+ const char *icon;
+ };
+
+ struct SPin : public SBase {
+ EPinType type;
+ const char *icon;
+ const char *pinid;
+ };
+
+ struct SAlbum : public SBase {
+ struct SContent contents[BUS_DATA_ALBUM_CONTENT_MAX];
+ int content_cnt;
+ };
+
+ struct SAction {
+ EActionOp action;
+ const char *actor;
+ const char *args;
+ };
+
+ struct SCallback : public CBaseBus::SCallback {
+ bool (*cbAddLabel)(SLabel *opdata, void *data);
+ bool (*cbAddAlbum)(SAlbum *opdata, SAction *act, void *data);
+ bool (*cbAddContent)(SContent *opdata, SAction *act, void *data);
+ bool (*cbAddPin)(SPin *opdata, SAction *act, void *data);
+ bool (*cbDelContent)(const char *svcid, int ctnt_id, void *data);
+ bool (*cbDelAll)(const char *svcid, bool reload, void *data);
+ };
+
+private:
+ struct SBus *m;
+
+protected:
+ virtual bool t_OnEvent(const char *method, GVariant *param);
+
+ bool t_EventAddLabel(GVariant *param);
+ bool t_EventAddAlbum(GVariant *param);
+ bool t_EventAddContent(GVariant *param);
+ bool t_EventAddPin(GVariant *param);
+ bool t_EventDelContent(GVariant *param);
+ bool t_EventDelAllContent(GVariant *param);
+
+protected:
+ bool t_GetContent(CBus::SContent *content);
+ bool t_GetContentArray(CBus::SContent contents[], int arraymax, int *cnt);
+ void t_ReleaseContentArray(struct CBus::SContent contents[], int arraymax);
+
+public:
+ //! Constructor
+ CBus() : CParcel(NULL), m(0) {}
+ //! Destructor
+ virtual ~CBus() {}
+ //! Whether this instance is created.
+ bool FlagCreate(void) { return !!m; }
+
+ //! Initializes bus.
+ bool Create(const SCallback *callback);
+ //! Finalizes bus.
+ virtual void Destroy(void);
+};
+
+
+int bus_change_user(const char *username, const char *password);
+
+
+#endif /* __BUS_H__ */
--- /dev/null
+#ifndef __COMMON_H__
+#define __COMMON_H__
+
+
+#include "dbg.h"
+
+
+#define ASSERT(exp) if (!(exp)) { _DBG(#exp); int* a = 0; *a = 5; }
+
+#define _CREATE_BEGIN int ___fail = 0;
+#define _CHECK(exp) do { if (!(exp)) { ___fail = 1; _DBG("_CHECK FAIL"); break; }
+#define _CHECK_FAIL } while (0); if (___fail != 0) ___fail++; if (___fail > 2)
+#define _CREATE_END_AND_CATCH if (___fail != 0)
+#define _WHEN_SUCCESS if (___fail == 0)
+#define _COMMAND if (___fail == 0)
+
+
+#endif /* __COMMON_H__ */
Evas_Coord y;
struct _cbar_item *cur;
- struct engine *eng;
+ CEngine *eng;
enum _cbar_state state;
struct bar_info *cbar;
enum bar_direction pin_dir;
Evas_Object *ic;
Elm_Transit *trans;
- struct engine_bar_item *it;
+ CEngineBarItem *it;
Eina_Bool dirty;
struct _cbar_data *bar;
struct bar_info *dbar;
return r ? BAR_EVENT_DONE : BAR_EVENT_PASS;
}
-static int _launch_app(struct bar_info *info)
+static bool _launch_app(struct bar_info *info)
{
struct _cbar_data *bar;
struct _cbar_item *item;
if (!info || !info->data)
- return -1;
+ return false;
bar = (struct _cbar_data *)info->data;
item = bar->cur;
if (!item) {
_ERR("Invalid argument");
- return -1;
+ return false;
}
- return engine_bar_item_launch(item->it);
+ return item->it->Launch();
}
static void _locate_edit_item(Evas_Object *eo, Evas_Object *p,
}
static inline Evas_Object *_add_cbar_item_bg(Evas_Object *,
- struct engine_bar_item *);
+ CEngineBarItem *);
static Eina_Bool _swap_pin(struct _cbar_data *bar);
static Eina_Bool _change_edit_mode(struct _cbar_data *bar);
cnt = 0;
EINA_LIST_FOREACH(bar->list, l, obj) {
item = (struct _cbar_item *)obj;
- if (engine_bar_item_get_is_pinned(item->it)) {
+ if (item->it->IsPinned()) {
if (item == bar->cur)
i = cnt;
cnt++;
bar = (struct _cbar_data *)data;
item = bar->cur;
- if (engine_bar_item_get_is_pinned(item->it))
+ if (item->it->IsPinned())
_change_edit_mode(bar);
return ECORE_CALLBACK_DONE;
item = bar->cur;
- r = engine_bar_item_del_pin(bar->eng, item->it);
+ r = bar->eng->DelPin(item->it);
if (r < 0) {
_ERR("failed to del pin");
return;
elm_object_focus_allow_set(popup, EINA_FALSE);
evas_object_show(popup);
snprintf(buf, sizeof(buf), "%s %s?", MESSAGE_DELETE,
- _trim((char *)engine_bar_item_get_name(item->it)));
+ _trim((char *)item->it->Str(CEngineBarItem::VSTR_NAME)));
elm_object_text_set(popup, buf);
r = _add_btn(popup, item);
static int _update(struct bar_info *info, void *eng, void *data);
+
static Eina_Bool _swap_pin(struct _cbar_data *bar)
{
struct _cbar_item *item, *_item, *swap_item;
Eina_List *l;
- int i, cnt, r;
+ int i, cnt;
void *obj;
if (!bar || !bar->cur || !bar->list) {
return EINA_FALSE;
}
- r = engine_bar_item_swap_pin(bar->eng, item->it, swap_item->it);
- if (r < 0) {
+ if (!bar->eng->Swap(item->it, swap_item->it)) {
_ERR("failed to swap pin");
return EINA_FALSE;
}
{
struct _cbar_data *bar;
Ecore_Event_Key *ev;
- int r;
if (!info || !info->data || !ei)
return BAR_EVENT_ERROR;
bar->key_timer = NULL;
if (bar->state == CBAR_STATE_CBAR) {
- r = _launch_app(info);
- if (r > 0)
+ if (_launch_app(info) == true)
return BAR_EVENT_DONE;
}
} else if (!strcmp(ev->keyname, KEY_UP) ||
}
static inline Evas_Object *_add_cbar_item_bg(Evas_Object *base,
- struct engine_bar_item *it)
+ CEngineBarItem *it)
{
Evas_Object *bg;
int r, g, b;
g = ITEM_DEFAULT_BG_G;
b = ITEM_DEFAULT_BG_B;
- engine_bar_item_get_color(it, &r, &g, &b);
+ it->GetColor(&r, &g, &b);
evas_object_color_set(bg, r, g, b, 255);
return bg;
elm_object_signal_emit(bar->ly, SIG_SHOW_DBAR, SRC_PROG);
}
-static void _updated(struct engine_bar_item *it, void *data)
+static void _updated(CEngineBarItem *it, void *data)
{
struct _cbar_item *item;
bar->key_timer = NULL;
if (bar->state == CBAR_STATE_CBAR)
- engine_bar_item_launch(item->it);
+ item->it->Launch();
}
static void _lbl_start_slide(void *data, Evas_Object *obj, void *ei)
}
static Evas_Object *_new_cbar_item(Evas_Object *p,
- struct _cbar_item *item, struct engine_bar_item *it)
+ struct _cbar_item *item, CEngineBarItem *it)
{
Evas_Object *ly, *eo, *lbl, *ic;
goto err;
elm_object_part_content_set(ly, PART_BG2, eo);
- ic = _add_icon(ly, engine_bar_item_get_icon(it));
+ ic = _add_icon(ly, it->Str(CEngineBarItem::VSTR_ICON));
if (!ic)
goto err;
elm_object_part_content_set(ly, PART_ICON, ic);
- eo = _add_icon(ly, engine_bar_item_get_icon_focus(it));
+ eo = _add_icon(ly, it->Str(CEngineBarItem::VSTR_ICON_FOCUS));
if (!eo)
goto err;
elm_object_part_content_set(ly, PART_ICON_FOCUS, eo);
- lbl = _add_label(ly, _trim((char *)engine_bar_item_get_name(it)));
+ lbl = _add_label(ly, _trim((char *)it->Str(CEngineBarItem::VSTR_NAME)));
if (!lbl)
goto err;
elm_object_part_content_set(ly, PART_NAME, lbl);
}
static struct _cbar_item *_pack_item(struct _cbar_data *bar,
- struct engine_bar_item *it)
+ CEngineBarItem *it)
{
Evas_Object *base;
struct _cbar_item *item;
item->bar = bar;
item->it = it;
- if (engine_bar_item_get_is_pinned(it)) {
+ if (it->IsPinned()) {
item->dirty = EINA_FALSE;
return item;
}
struct _cbar_data *bar;
const Eina_List *list;
Eina_List *l;
- struct engine_bar_item *it;
+ CEngineBarItem *it;
struct _cbar_item *item;
int cnt, r;
void *obj;
- struct engine *engine;
+ CEngine *engine;
if (!info || !info->data) {
_ERR("Invalid argument");
}
bar = (struct _cbar_data *)info->data;
- engine = (struct engine *)eng;
+ engine = (CEngine *)eng;
EINA_LIST_FREE(bar->list, obj) {
item = (struct _cbar_item *)obj;
- engine_bar_item_set_update_cb(item->it, NULL, NULL);
- engine_bar_item_set_pin_update_cb(engine, NULL, NULL);
+ item->it->SetUpdateCallback(NULL, NULL);
+ engine->SetUpdateCallback(NULL, NULL);
evas_object_del(item->eo);
if (item->dbar)
item->dbar->ops->release(item->dbar);
bar->list = NULL;
cnt = 0;
- list = engine_get_bar_items(engine);
+ list = engine->BarItemsList();
if (!list)
return cnt;
EINA_LIST_FOREACH((Eina_List *)list, l, obj) {
- it = (struct engine_bar_item *)obj;
- r = strcmp(engine_bar_item_get_in(it), "custombar");
+ it = (CEngineBarItem *)obj;
+ r = strcmp(it->Str(CEngineBarItem::VSTR_IN), "custombar");
if (r != 0)
continue;
continue;
bar->list = eina_list_append(bar->list, item);
- engine_bar_item_set_update_cb(item->it, _updated, item);
+ item->it->SetUpdateCallback(_updated, item);
cnt++;
}
_set_circular_focus(bar);
- engine_bar_item_set_pin_update_cb(engine, _update_pin, info);
+ engine->SetUpdateCallback(_update_pin, info);
bar->eng = engine;
return cnt;
if (bar) {
EINA_LIST_FREE(bar->list, obj) {
item = (struct _cbar_item *)obj;
- engine_bar_item_set_update_cb(item->it, NULL, NULL);
+ item->it->SetUpdateCallback(NULL, NULL);
evas_object_del(item->eo);
if (item->dbar)
item->dbar->ops->release(item->dbar);
free(item);
}
- engine_bar_item_set_pin_update_cb(bar->eng, NULL, NULL);
+
+ bar->eng->SetUpdateCallback(NULL, NULL);
evas_object_del(bar->pin);
free(bar);
bar = NULL;
struct bar_cb focus_cb;
struct engine *eng;
- struct engine_dbar_item *it;
+ CEngineDBarItem *it;
struct bar_info *xbar;
enum _xbar_state state;
bar->state = XBAR_STATE_XBAR;
}
-static enum engine_dbar_content_type _get_ctnt_type(struct engine_dbar_item *it)
+static CEngineDBarItemContent::EType _get_ctnt_type(CEngineDBarItem *it)
{
- struct engine_dbar_item_content *ctnt;
+ CEngineDBarItemContent *ctnt;
const Eina_List *ctnts;
if (!it) {
_ERR("Invalid argument");
- return ENGINE_DBAR_CONTENT_TYPE_MAX;
+ return CEngineDBarItemContent::TYPE_MAX;
}
- ctnts = engine_dbar_item_get_contents(it);
+ ctnts = it->ContentsList();
if (!ctnts)
- return ENGINE_DBAR_CONTENT_TYPE_MAX;
+ return CEngineDBarItemContent::TYPE_MAX;
- ctnt = (struct engine_dbar_item_content *)eina_list_data_get(ctnts);
+ ctnt = (CEngineDBarItemContent *)eina_list_data_get(ctnts);
if (!ctnt)
- return ENGINE_DBAR_CONTENT_TYPE_MAX;
+ return CEngineDBarItemContent::TYPE_MAX;
- return engine_dbar_item_get_content_type(ctnt);
+ return ctnt->Type();
}
static void _del_item(struct _xbar_data *bar)
{
- enum engine_dbar_content_type type;
+ CEngineDBarItemContent::EType type;
int r;
if (!bar) {
return;
}
- r = engine_dbar_item_del(bar->it, type);
+ r = bar->it->Del(type);
if (r < 0) {
_ERR("failed to delete dbar item");
return;
static void _del_all_item(struct _xbar_data *bar)
{
- enum engine_dbar_content_type type;
+ CEngineDBarItemContent::EType type;
int r;
if (!bar) {
}
static Evas_Object *_load_popup(Evas_Object *base,
- enum engine_dbar_content_type type)
+ CEngineDBarItemContent::EType type)
{
Evas_Object *popup;
char title[TITLE_MAX];
evas_object_show(popup);
switch (type) {
- case ENGINE_DBAR_CONTENT_TYPE_NOTIFICATION_NOTI:
+ case CEngineDBarItemContent::TYPE_NOTIFICATION_NOTI:
snprintf(title, sizeof(title), "%s %s",
TITLE_DELETE, TITLE_NOTIFICATION);
snprintf(message, sizeof(message), "%s %s?",
MESSAGE_DELETE, MESSAGE_NOTIFICATION);
break;
- case ENGINE_DBAR_CONTENT_TYPE_HISTORY:
+ case CEngineDBarItemContent::TYPE_HISTORY:
snprintf(title, sizeof(title), "%s %s",
TITLE_DELETE, TITLE_HISTORY);
snprintf(message, sizeof(message), "%s %s?",
{
struct _xbar_data *bar;
Evas_Object *popup, *win;
- enum engine_dbar_content_type type;
+ CEngineDBarItemContent::EType type;
int r;
if (!info) {
}
static inline Evas_Object *_add_item_bg(Evas_Object *base,
- struct engine_dbar_item *it)
+ CEngineDBarItem *it)
{
Evas_Object *bg;
int r, g, b;
g = ITEM_DEFAULT_BG_G;
b = ITEM_DEFAULT_BG_B;
- engine_dbar_item_get_color(it, &r, &g, &b);
+ it->GetColor(&r, &g, &b);
evas_object_color_set(bg, r, g, b, 255);
return bg;
static int _update(struct bar_info *info, void *eng, void *data)
{
struct _xbar_data *bar;
- struct engine_dbar_item *it;
+ CEngineDBarItem *it;
Evas_Object *bg1, *bg2, *eo;
Evas_Coord x, y;
bar = (struct _xbar_data *)info->data;
eo = (Evas_Object*)data;
- it = (struct engine_dbar_item *)eng;
+ it = (CEngineDBarItem *)eng;
if (!bar->bg) {
bg1 = _add_item_bg(bar->ly, it);
#define STYLE_TITLE "title"
#define STYLE_VIDEO "video"
#define STYLE_AUDIO "audio"
-#define STYLE_ALBUM "album"
+const char *STYLE_ALBUM = "album";
+//#define STYLE_ALBUM "album"
#define STYLE_COMMON "common"
#define DEFAULT_TITLE "No Information"
struct _dbar_item {
Evas_Object *eo;
- struct engine_dbar_item *it;
+ CEngineDBarItem *it;
struct _dbar_data *bar;
struct bar_info *xbar;
Eina_Bool focus;
};
struct _dbar_item_loader {
- enum engine_dbar_item_style style;
- Evas_Object *(*loader)(Evas_Object *p, struct engine_dbar_item *it,
+ CEngineDBarItem::EStyle style;
+ Evas_Object *(*loader)(Evas_Object *p, CEngineDBarItem *it,
Eina_Bool *fill);
};
return;
item = (struct _dbar_item *)data;
- engine_dbar_item_launch(item->it);
+ item->it->Launch();
}
static int _launch_app(struct bar_info *info)
return -1;
}
- return engine_dbar_item_launch(item->it);
+ return item->it->Launch();
}
static inline Evas_Object *_load_bg(Evas_Object *base,
- struct engine_dbar_item *it)
+ CEngineDBarItem *it)
{
Evas_Object *bg;
int r, g, b;
r = 128;
g = 128;
b = 128;
- engine_dbar_item_get_color(it, &r, &g, &b);
+ it->GetColor(&r, &g, &b);
evas_object_color_set(bg, r, g, b, 255);
return bg;
}
-static Evas_Object *_load_title(Evas_Object *p, struct engine_dbar_item *it,
+static Evas_Object *_load_title(Evas_Object *p, CEngineDBarItem *it,
Eina_Bool *fill)
{
Evas_Object *ly;
if (!p || !it)
return NULL;
- name = engine_dbar_item_get_name(it);
+ name = it->Str(CEngineDBarItem::VSTR_NAME);
if (!name)
name = "";
elm_layout_file_set(ly, EDJEFILE, GRP_DBAR_LABEL);
elm_object_part_text_set(ly, PART_TITLE,
- engine_dbar_item_get_name(it));
+ it->Str(CEngineDBarItem::VSTR_NAME));
if (fill)
*fill = EINA_TRUE;
}
static Evas_Object *_load_ly(Evas_Object *p,
- struct engine_dbar_item *it,
+ CEngineDBarItem *it,
const char *group)
{
Evas_Object *ly;
}
static Evas_Object *_load_content_broadcast(Evas_Object *p,
- const char *style, struct engine_dbar_item_content *ctnt,
- struct engine_dbar_item *it)
+ const char *style, CEngineDBarItemContent *ctnt,
+ CEngineDBarItem *it)
{
Evas_Object *ly, *lbl;
const char *channel, *progname, *progtime, *icon;
if (!ly)
return NULL;
- channel = engine_dbar_item_get_content_subtitle(ctnt);
+ channel = ctnt->Str(CEngineDBarItemContent::VSTR_SUBTITLE);
_trim((char *)channel);
- progname = engine_dbar_item_get_content_description(ctnt);
+ progname = ctnt->Str(CEngineDBarItemContent::VSTR_DESCRIPTION);
_trim((char *)progname);
- progtime = engine_dbar_item_get_content_detail(ctnt);
+ progtime = ctnt->Str(CEngineDBarItemContent::VSTR_DETAIL);
_trim((char *)progtime);
- icon = engine_dbar_item_get_content_icon(ctnt);
+ icon = ctnt->Str(CEngineDBarItemContent::VSTR_ICON);
if (icon && strlen(icon) != 0)
_load_funcs(_trim((char *)icon), ly);
lbl = _add_label(ly, STYLE_LABEL_SLIDE_CENTER_40,
- _trim((char *)engine_dbar_item_get_name(it)));
+ _trim((char *)it->Str(CEngineDBarItem::VSTR_NAME)));
if (!lbl)
goto err;
elm_object_part_content_set(ly, PART_NUMBER, lbl);
}
static Evas_Object *_load_content_history(Evas_Object *p,
- const char *style, struct engine_dbar_item_content *ctnt,
- struct engine_dbar_item *it)
+ const char *style, CEngineDBarItemContent *ctnt,
+ CEngineDBarItem *it)
{
Evas_Object *ly;
const char *name;
}
elm_object_part_content_set(ly, PART_BG2, bg);
- name = engine_dbar_item_get_name(it);
+ name = it->Str(CEngineDBarItem::VSTR_NAME);
_trim((char *)name);
if (!name || strlen(name) <= 0)
name = _(DEFAULT_TITLE);
- _put_icon(ly, engine_dbar_item_get_content_icon(ctnt),
+ _put_icon(ly, ctnt->Str(CEngineDBarItemContent::VSTR_ICON),
PART_ICON, SIG_SHOW_DEFAULT_ICON, SRC_PROG,
EINA_FALSE);
}
static Evas_Object *_load_content_common(Evas_Object *p,
- const char *style, struct engine_dbar_item_content *ctnt,
- struct engine_dbar_item *it)
+ const char *style, CEngineDBarItemContent *ctnt,
+ CEngineDBarItem *it)
{
Evas_Object *ly;
const char *name;
if (!ly)
return NULL;
- name = engine_dbar_item_get_name(it);
+ name = it->Str(CEngineDBarItem::VSTR_NAME);
_trim((char *)name);
if (!name || strlen(name) <= 0)
name = _(DEFAULT_TITLE);
- _put_icon(ly, engine_dbar_item_get_content_thumbnail(ctnt),
+ _put_icon(ly, ctnt->Str(CEngineDBarItemContent::VSTR_THUMBNAIL),
PART_THUMB, SIG_SHOW_DEFAULT_THUMB, SRC_PROG,
EINA_FALSE);
- _put_icon(ly, engine_dbar_item_get_content_icon(ctnt),
+ _put_icon(ly, ctnt->Str(CEngineDBarItemContent::VSTR_ICON),
PART_ICON, SIG_SHOW_DEFAULT_ICON, SRC_PROG,
EINA_FALSE);
elm_object_part_text_set(ly, PART_TITLE, name);
elm_object_part_text_set(ly, PART_SUBTITLE, _trim((char *)
- engine_dbar_item_get_content_subtitle(ctnt)));
+ ctnt->Str(CEngineDBarItemContent::VSTR_SUBTITLE)));
return ly;
}
static Evas_Object *_load_content_music(Evas_Object *p,
- const char *style, struct engine_dbar_item_content *ctnt,
- struct engine_dbar_item *it)
+ const char *style, CEngineDBarItemContent *ctnt,
+ CEngineDBarItem *it)
{
Evas_Object *ly;
Evas_Object *lbl;
if (!ly)
return NULL;
- name = engine_dbar_item_get_name(it);
+ name = it->Str(CEngineDBarItem::VSTR_NAME);
_trim((char *)name);
if (!name || strlen(name) <= 0)
name = _(DEFAULT_TITLE);
- _put_icon(ly, engine_dbar_item_get_content_thumbnail(ctnt),
+ _put_icon(ly, ctnt->Str(CEngineDBarItemContent::VSTR_THUMBNAIL),
PART_THUMB, SIG_SHOW_DEFAULT_THUMB, SRC_PROG,
EINA_FALSE);
- _put_icon(ly, engine_dbar_item_get_content_icon(ctnt),
+ _put_icon(ly, ctnt->Str(CEngineDBarItemContent::VSTR_ICON),
PART_ICON, SIG_SHOW_DEFAULT_ICON, SRC_PROG,
EINA_FALSE);
elm_object_part_content_set(ly, PART_TITLE, lbl);
elm_object_part_text_set(ly, PART_SUBTITLE, _trim((char *)
- engine_dbar_item_get_content_subtitle(ctnt)));
+ ctnt->Str(CEngineDBarItemContent::VSTR_SUBTITLE)));
return ly;
}
static Evas_Object *_load_content_source(Evas_Object *p,
- const char *style, struct engine_dbar_item_content *ctnt,
- struct engine_dbar_item *it)
+ const char *style, CEngineDBarItemContent *ctnt,
+ CEngineDBarItem *it)
{
Evas_Object *ly;
const char *name;
if (!ly)
return NULL;
- _put_icon(ly, engine_dbar_item_get_content_thumbnail(ctnt),
+ _put_icon(ly, ctnt->Str(CEngineDBarItemContent::VSTR_THUMBNAIL),
PART_THUMB, SIG_SHOW_DEFAULT_THUMB, SRC_PROG,
EINA_FALSE);
- name = engine_dbar_item_get_name(it);
+ name = it->Str(CEngineDBarItem::VSTR_NAME);
_trim((char *)name);
if (!name || strlen(name) <= 0)
name = _(UNKNOWN_DEVICE);
elm_object_part_text_set(ly, PART_TITLE, name);
elm_object_part_text_set(ly, PART_SUBTITLE, _trim((char *)
- engine_dbar_item_get_content_subtitle(ctnt)));
+ ctnt->Str(CEngineDBarItemContent::VSTR_SUBTITLE)));
return ly;
}
static Evas_Object *_load_content_notification(Evas_Object *p,
- const char *style, struct engine_dbar_item_content *ctnt,
- struct engine_dbar_item *it)
+ const char *style, CEngineDBarItemContent *ctnt,
+ CEngineDBarItem *it)
{
Evas_Object *ly;
const char *title, *subtitle, *icon, *description;
Evas_Object *bg;
- icon = engine_dbar_item_get_content_icon(ctnt);
- title = engine_dbar_item_get_name(it);
- subtitle = engine_dbar_item_get_content_subtitle(ctnt);
- description = engine_dbar_item_get_content_description(ctnt);
+ icon = ctnt->Str(CEngineDBarItemContent::VSTR_ICON);
+ title = it->Str(CEngineDBarItem::VSTR_NAME);
+ subtitle = ctnt->Str(CEngineDBarItemContent::VSTR_SUBTITLE);
+ description = ctnt->Str(CEngineDBarItemContent::VSTR_DESCRIPTION);
ly = _load_ly(p, it, GRP_DBAR_NOTIFICATION);
if (!ly)
return ly;
}
-static Evas_Object *_load_content(Evas_Object *p, struct engine_dbar_item *it,
+static Evas_Object *_load_content(Evas_Object *p, CEngineDBarItem *it,
Eina_Bool *fill)
{
- struct engine_dbar_item_content *ctnt;
+ CEngineDBarItemContent *ctnt;
const Eina_List *ctnts;
Evas_Object *eo;
- ctnts = engine_dbar_item_get_contents(it);
+ ctnts = it->ContentsList();
if (!ctnts)
return NULL;
- ctnt = (struct engine_dbar_item_content *)eina_list_data_get(ctnts);
+ ctnt = (CEngineDBarItemContent *)eina_list_data_get(ctnts);
if (!ctnt)
return NULL;
eo = NULL;
- switch (engine_dbar_item_get_content_type(ctnt)) {
- case ENGINE_DBAR_CONTENT_TYPE_IMAGE:
- case ENGINE_DBAR_CONTENT_TYPE_VIDEO:
+ switch (ctnt->Type()) {
+ case CEngineDBarItemContent::TYPE_IMAGE:
+ case CEngineDBarItemContent::TYPE_VIDEO:
eo = _load_content_common(p, GRP_DBAR_COMMON, ctnt, it);
if (eo && fill)
*fill = EINA_TRUE;
break;
- case ENGINE_DBAR_CONTENT_TYPE_BROADCAST:
+ case CEngineDBarItemContent::TYPE_BROADCAST:
eo = _load_content_broadcast(p, GRP_DBAR_BROADCAST, ctnt, it);
if (eo && fill)
*fill = EINA_TRUE;
break;
- case ENGINE_DBAR_CONTENT_TYPE_APP:
+ case CEngineDBarItemContent::TYPE_APP:
eo = _load_content_common(p, GRP_DBAR_APP, ctnt, it);
if (eo && fill)
*fill = EINA_TRUE;
break;
- case ENGINE_DBAR_CONTENT_TYPE_MUSIC:
+ case CEngineDBarItemContent::TYPE_MUSIC:
eo = _load_content_music(p, GRP_DBAR_MUSIC, ctnt, it);
if (eo && fill)
*fill = EINA_FALSE;
break;
- case ENGINE_DBAR_CONTENT_TYPE_SOURCE:
+ case CEngineDBarItemContent::TYPE_SOURCE:
eo = _load_content_source(p, GRP_DBAR_SOURCE, ctnt, it);
if (eo && fill)
*fill = EINA_FALSE;
break;
- case ENGINE_DBAR_CONTENT_TYPE_NOTIFICATION_ONGOING:
- case ENGINE_DBAR_CONTENT_TYPE_NOTIFICATION_NOTI:
+ case CEngineDBarItemContent::TYPE_NOTIFICATION_ONGOING:
+ case CEngineDBarItemContent::TYPE_NOTIFICATION_NOTI:
eo = _load_content_notification(p, NULL, ctnt, it);
if (eo && fill)
*fill = EINA_TRUE;
break;
- case ENGINE_DBAR_CONTENT_TYPE_HISTORY:
+ case CEngineDBarItemContent::TYPE_HISTORY:
eo = _load_content_history(p, GRP_DBAR_HISTORY, ctnt, it);
if (eo && fill)
*fill = EINA_TRUE;
SIG_SHOW_THUMB5_VIDEO,
SIG_SHOW_THUMB6_VIDEO
};
- struct engine_dbar_item_content *ctnt;
+ CEngineDBarItemContent *ctnt;
if (!p || !ctnts) {
_ERR("Invalid argument");
/* TODO, show default photo/video icon */
for (i = 0; i < ctnt_cnt; i++) {
- ctnt = (struct engine_dbar_item_content *)eina_list_data_get(l);
- thumb = engine_dbar_item_get_content_thumbnail(ctnt);
+ ctnt = (CEngineDBarItemContent *)eina_list_data_get(l);
+ thumb = ctnt->Str(CEngineDBarItemContent::VSTR_THUMBNAIL);
ic = evas_object_image_add(evas_object_evas_get(ly));
if (!ic) {
evas_object_del(ly);
_img_resized, NULL);
elm_object_part_content_set(ly, parts[i], ic);
- if (engine_dbar_item_get_content_type(ctnt) ==
- ENGINE_DBAR_CONTENT_TYPE_VIDEO)
+ if (ctnt->Type() ==
+ CEngineDBarItemContent::TYPE_VIDEO)
elm_object_signal_emit(ly, sig_video[i], SRC_PROG);
l = eina_list_next(l);
return ly;
}
-static Evas_Object *_load_album(Evas_Object *p, struct engine_dbar_item *it,
+static Evas_Object *_load_album(Evas_Object *p, CEngineDBarItem *it,
Eina_Bool *fill)
{
Evas_Object *ly;
if (!ly)
return NULL;
- name = engine_dbar_item_get_name(it);
+ name = it->Str(CEngineDBarItem::VSTR_NAME);
if (!name)
name = "No Title";
- ly2 = _load_album_thumb(ly, engine_dbar_item_get_contents(it));
+ ly2 = _load_album_thumb(ly, it->ContentsList());
if (!ly2) {
evas_object_del(ly);
return NULL;
return ly;
}
-Evas_Object *_item_load(Evas_Object *p, struct engine_dbar_item *it,
+Evas_Object *_item_load(Evas_Object *p, CEngineDBarItem *it,
Eina_Bool *fill, Eina_Bool *focus)
{
static struct _dbar_item_loader loaders[] = {
{
- .style = ENGINE_DBAR_ITEM_STYLE_CONTENT,
+ .style = CEngineDBarItem::STYLE_CONTENT,
.loader = _load_content
},
{
- .style = ENGINE_DBAR_ITEM_STYLE_LABEL,
+ .style = CEngineDBarItem::STYLE_LABEL,
.loader = _load_title
},
{
- .style = ENGINE_DBAR_ITEM_STYLE_ALBUM,
+ .style = CEngineDBarItem::STYLE_ALBUM,
.loader = _load_album
},
};
Evas_Object *eo;
- enum engine_dbar_item_style style;
+ CEngineDBarItem::EStyle style;
int i;
if (!it) {
return NULL;
}
- style = engine_dbar_item_get_style(it);
- if (style >= ENGINE_DBAR_ITEM_STYLE_MAX)
- style = ENGINE_DBAR_ITEM_STYLE_CONTENT;
+ style = (CEngineDBarItem::EStyle)it->Int(CEngineDBarItem::VINT_STYLE);
+ if (style >= CEngineDBarItem::STYLE_MAX)
+ style = CEngineDBarItem::STYLE_CONTENT;
for (i = 0; i < (int) (sizeof(loaders) / sizeof(*loaders)); i++) {
if (loaders[i].style == style) {
if (!eo)
return NULL;
- if (style == ENGINE_DBAR_ITEM_STYLE_LABEL)
+ if (style == CEngineDBarItem::STYLE_LABEL)
*focus = EINA_FALSE;
else
*focus = EINA_TRUE;
}
static struct _dbar_item *_pack_item(struct _dbar_data *bar,
- struct engine_dbar_item *it)
+ CEngineDBarItem *it)
{
Evas_Object *eo;
struct _dbar_item *item;
int row, col;
int step;
int r;
- enum engine_dbar_content_type type;
- struct engine_dbar_item_content *ctnt;
+ CEngineDBarItemContent::EType type;
+ CEngineDBarItemContent *ctnt;
if (!bar || !it)
return NULL;
elm_object_signal_callback_add(eo, SIG_UNFOCUS_TO_HBAR, SRC_PROG,
_unfocused, item);
- ctnt = (struct engine_dbar_item_content *)
- eina_list_data_get(engine_dbar_item_get_contents(it));
+ ctnt = (CEngineDBarItemContent *)
+ eina_list_data_get(it->ContentsList());
if (!ctnt) {
_ERR("failed to get ci");
return item;
}
- type = engine_dbar_item_get_content_type(ctnt);
- if ((type == ENGINE_DBAR_CONTENT_TYPE_NOTIFICATION_NOTI ||
- type == ENGINE_DBAR_CONTENT_TYPE_HISTORY) &&
+ type = ctnt->Type();
+ if ((type == CEngineDBarItemContent::TYPE_NOTIFICATION_NOTI ||
+ type == CEngineDBarItemContent::TYPE_HISTORY) &&
item->focus) {
r = _init_child_bars(item);
if (r < 0) {
struct _dbar_data *bar;
const Eina_List *list;
Eina_List *l;
- struct engine_dbar_item *it;
+ CEngineDBarItem *it;
struct _dbar_item *item;
const char *noctnt_title;
const char *noctnt_desc;
int cnt;
void *obj;
- struct engine_bar_item *engine;
+ CEngineBarItem *engine;
if (!info || !info->data) {
_ERR("Invalid argument");
}
bar = (struct _dbar_data *)info->data;
- engine = (struct engine_bar_item *)eng;
+ engine = (CEngineBarItem *)eng;
elm_table_clear(bar->tbl, EINA_TRUE);
bar->tbl_idx = 0;
bar->cur = NULL;
bar->list = NULL;
- engine_bar_item_get_content_column(engine, &bar->content_column);
+ bar->content_column = engine->Int(CEngineBarItem::VINT_COLUMN);
cnt = 0;
- list = engine_get_dbar_items(engine);
+ list = engine->DBarItems();
if (!list) {
- noctnt_title = engine_bar_item_get_noctnt_title(engine);
- noctnt_desc = engine_bar_item_get_noctnt_desc(engine);
- elm_object_part_text_set(bar->ly,
- PART_DEFAULT_TITLE,
- noctnt_title ? noctnt_title : "");
- elm_object_part_text_set(bar->ly,
- PART_DEFAULT_DESC,
- noctnt_desc ? noctnt_desc : "");
+ noctnt_title = engine->Str(CEngineBarItem::VSTR_NOCTNT_TITLE);// > NoctntTitle();
+ noctnt_desc = engine->Str(CEngineBarItem::VSTR_NOCTNT_DESC);// > NoctntDesc();
+ elm_object_part_text_set(bar->ly, PART_DEFAULT_TITLE, noctnt_title ? noctnt_title : "");
+ elm_object_part_text_set(bar->ly, PART_DEFAULT_DESC, noctnt_desc ? noctnt_desc : "");
return cnt;
}
elm_object_part_text_set(bar->ly, PART_DEFAULT_TITLE, "");
elm_object_part_text_set(bar->ly, PART_DEFAULT_DESC, "");
EINA_LIST_FOREACH((Eina_List *)list, l, obj) {
- it = (struct engine_dbar_item *)obj;
+ it = (CEngineDBarItem *)obj;
item = _pack_item(bar, it);
if (!item)
continue;
#include <cynara-client.h>
#include <pwd.h>
+#include "common.h"
+#include "bus.h"
#include "engine.h"
#include "Parcel.h"
-#include "bus.h"
#include "client_bus.h"
#include "defs.h"
#include "dbg.h"
+
+
#define SECTION_USER "user"
#define SECTION_UBAR_ITEMS "ubar.items"
#define SECTION_ITEMS "items"
#define ATTR_CONTENT_COLUMN "content_column"
#define ATTR_IN "in"
-#define GUM_ATTR_NAME "username"
-#define GUM_ATTR_PASSWORD "secret"
-#define GUM_ATTR_USERTYPE "usertype"
-#define GUM_ATTR_UID "uid"
-#define GUM_ATTR_ICON "icon"
#define SIZE_32 32
#define SIZE_4 4
#define MULTIPLIER 1024
-#define PACKAGE_LIVE_TV "org.tizen.live-tv-ref"
-struct engine {
+
+
+struct SEngine {
struct {
char *name;
char *thumb_bg;
char *thumb;
- } user;
+ } user;
CBus *bus;
Eina_List *client_buslist;
void *update_cb_data;
};
-struct engine_bar_item {
- struct engine *eng;
- char *icon;
- char *icon_focus;
- char *name;
- char *svcid;
- char *bus_name;
- char *object_path;
- char *app;
- char *noctnt_title;
- char *noctnt_desc;
- int r;
- int g;
- int b;
- int content_column;
- Eina_List *dbar_its;
- int ctnt_id;
- char *in;
- char *args;
- char *pinid;
- CAppContentFavorite::EType type;
- Eina_Bool is_pinned;
-
- void (*update_cb)(struct engine_bar_item *it, void *data);
- void *update_cb_data;
-};
-
-struct engine_dbar_item_content {
- enum engine_dbar_content_type type;
- char *subtitle;
- char *description;
- char *detail;
- char *thumbnail;
- char *icon;
-};
-
-struct engine_ubar_item {
- struct engine *eng;
- char *name;
- char *thumb_bg;
- char *thumb;
- int age;
-};
-struct engine_dbar_item {
- int ctnt_id;
- struct engine_bar_item *hit;
- enum engine_dbar_item_style style;
- char *name;
- CBus::EActionOp action;
- char *actor;
- char *args;
- Eina_List *ctnts;
-};
static int _is_member_exist(JsonReader *reader, const char *member_name)
{
static JsonReader *_get_reader(JsonParser *parser)
{
- if (!parser) {
- _ERR("Invalid argument");
- return NULL;
- }
+ ASSERT(parser);
return json_reader_new(json_parser_get_root(parser));
}
-static inline void _unload_config_user(struct engine *eng)
-{
- if (!eng)
- return;
- free(eng->user.name);
- free(eng->user.thumb_bg);
- free(eng->user.thumb);
+void CEngine::_unload_config_user(void)
+{
+ free(m->user.name);
+ free(m->user.thumb_bg);
+ free(m->user.thumb);
}
-static int _read_color(JsonReader *reader, gint64 *r, gint64 *g, gint64 *b)
+bool _read_color(JsonReader *reader, gint64 *r, gint64 *g, gint64 *b)
{
- if (!reader || !r || !g || !b) {
- _ERR("Invalid argument");
- return -1;
- }
+ ASSERT(reader);
+ ASSERT(r && g && b);
if (!_is_member_exist(reader, ATTR_COLOR)) {
_ERR("There is no "ATTR_COLOR" attribute");
- return -1;
+
+ *r = 69;
+ *g = 143;
+ *b = 255;
+
+ return false;
}
json_reader_read_member(reader, ATTR_COLOR);
*r = _read_attr_int(reader, ATTR_RED);
*b = _read_attr_int(reader, ATTR_BLUE);
json_reader_end_member(reader);
- return 0;
+ return true;
}
static void _string_to_uppercase(char *str)
*(str++) = toupper(*str);
}
-static char *_get_unique_id(const char *object_path)
+static char *_get_unique_id(const char *object_path, char *uuid)
{
struct timezone timezone;
struct timeval timeval;
- char uuid[SIZE_32];
int len;
int i;
union {
for (i = 0; i < len; i++)
u2.t = u2.t + MULTIPLIER * (unsigned int)object_path[i];
- snprintf(uuid, sizeof(uuid), "%02x%02x.%02x%02x.%02x%02x.%02x%02x",
+ snprintf(uuid, SIZE_32, "%02x%02x.%02x%02x.%02x%02x.%02x%02x",
(unsigned char)u2.ct[3], (unsigned char)u2.ct[2],
(unsigned char)u2.ct[1], (unsigned char)u2.ct[0],
(unsigned char)u1.ct[3], (unsigned char)u1.ct[2],
return strdup(uuid);
}
-static struct engine_bar_item *_new_bar_item(JsonReader *reader, int idx)
+
+CEngineBarItem *CEngineBarItem::Alloc(JsonReader *reader, int idx)
{
- struct engine_bar_item *it;
+ CEngineBarItem *it;
const char *name, *icon, *icon_focus, *app, *in;
const char *object_path, *bus_name;
const char *noctnt_title, *noctnt_desc;
gint64 r, g, b;
gint64 column;
- if (!json_reader_read_element(reader, idx)) {
- _ERR("Cannot read element of index %d", idx);
- return NULL;
- }
-
- it = (struct engine_bar_item *)calloc(1, sizeof(*it));
- if (!it) {
- _ERR("calloc failed");
- return NULL;
- }
-
- name = _read_attr(reader, ATTR_NAME);
- if (!name)
- goto err;
- icon = _read_attr(reader, ATTR_ICON);
- if (!icon)
- goto err;
- icon_focus = _read_attr(reader, ATTR_ICON_FOCUS);
- if (!icon_focus)
- goto err;
- bus_name = _read_attr(reader, ATTR_BUS_NAME);
- if (!bus_name)
- goto err;
- object_path = _read_attr(reader, ATTR_OBJECT_PATH);
- if (!object_path)
- goto err;
- in = _read_attr(reader, ATTR_IN);
- if (!in)
- goto err;
- app = _read_attr(reader, ATTR_APP);
+ _CREATE_BEGIN{
+ _CHECK(json_reader_read_element(reader, idx));
+ _CHECK(it = new CEngineBarItem);
+ _CHECK(name = _read_attr(reader, ATTR_NAME));
+ _CHECK(icon = _read_attr(reader, ATTR_ICON));
+ _CHECK(icon_focus = _read_attr(reader, ATTR_ICON_FOCUS));
+ _CHECK(bus_name = _read_attr(reader, ATTR_BUS_NAME));
+ _CHECK(object_path = _read_attr(reader, ATTR_OBJECT_PATH));
+ _CHECK(in = _read_attr(reader, ATTR_IN));
+
+ _CHECK_FAIL{}
+ _CHECK_FAIL{}
+ _CHECK_FAIL{}
+ _CHECK_FAIL{}
+ _CHECK_FAIL{}
+ _CHECK_FAIL{}
+ _CHECK_FAIL{ delete it; }
+ _CHECK_FAIL{ json_reader_end_element(reader); }
+ } _CREATE_END_AND_CATCH{ return NULL; }
+
+ app = _read_attr(reader, ATTR_APP);
noctnt_title = _read_attr(reader, ATTR_NOCTNT_TITLE);
- noctnt_desc = _read_attr(reader, ATTR_NOCTNT_DESC);
- column = _read_attr_int(reader, ATTR_CONTENT_COLUMN);
+ noctnt_desc = _read_attr(reader, ATTR_NOCTNT_DESC);
+ column = _read_attr_int(reader, ATTR_CONTENT_COLUMN);
if (!column)
column = 1;
- if (_read_color(reader, &r, &g, &b) != 0) {
- r = 69;
- g = 143;
- b = 255;
- }
-
+ _read_color(reader, &r, &g, &b);
json_reader_end_element(reader);
-
- it->name = strdup(name);
- it->icon = strdup(icon);
- it->icon_focus = strdup(icon_focus);
- it->object_path = strdup(object_path);
- it->bus_name = strdup(bus_name);
- it->svcid = _get_unique_id(it->object_path);
- it->in = strdup(in);
- if (app)
- it->app = strdup(app);
- if (noctnt_title)
- it->noctnt_title = strdup(noctnt_title);
- if (noctnt_desc)
- it->noctnt_desc = strdup(noctnt_desc);
- it->r = r;
- it->g = g;
- it->b = b;
- it->content_column = column;
+
+ char uuid[SIZE_32];
+ it->SetStr(VSTR_NAME, name); // it->SetName(name);
+ it->SetStr(VSTR_ICON, icon); // it->SetIcon(icon);
+ it->SetStr(VSTR_ICON_FOCUS, icon_focus);// it->SetIconFocus(icon_focus);
+ it->SetStr(VSTR_OBJECT_PATH, object_path);// it->SetObjectPath(object_path);
+ it->SetStr(VSTR_BUS_NAME, bus_name);// it->SetBusName(bus_name);
+ it->SetStr(VSTR_SVC_ID, _get_unique_id(object_path, uuid));// it->SetSvcId(id);
+ it->SetStr(VSTR_IN, in);// it->SetIn(in);
+ it->SetStr(VSTR_APP, app);// it->SetApp(app);
+ it->SetStr(VSTR_NOCTNT_TITLE, noctnt_title);// it->SetNoctntTitle(noctnt_title);
+ it->SetStr(VSTR_NOCTNT_DESC, noctnt_desc);// it->SetNoctntDesc(noctnt_desc);
+ it->SetColor(r, g, b);
+ it->SetInt(VINT_COLUMN, column);
return it;
-
-err:
- json_reader_end_element(reader);
- free(it);
-
- return NULL;
}
-static inline void _unload_bar_item(struct engine_bar_item *it)
-{
- if (!it)
- return;
-
- free(it->name);
- free(it->icon);
- free(it->icon_focus);
- free(it->svcid);
- free(it->bus_name);
- free(it->object_path);
- free(it->app);
- free(it->args);
- free(it->noctnt_title);
- free(it->noctnt_desc);
- free(it->in);
- free(it);
-}
-static int _load_bar_items(JsonReader *reader, struct engine *eng)
+bool CEngine::_load_bar_items(JsonReader *reader)
{
- struct engine_bar_item *it;
+ ASSERT(reader);
+
+ CEngineBarItem *it;
int i, cnt;
CClientBus *cbus;
- if (!reader || !eng) {
- _ERR("Invalid argument");
- return -1;
- }
-
if (!_is_member_exist(reader, SECTION_ITEMS)) {
_ERR("There is no "SECTION_ITEMS" field");
- return -1;
+ return false;
}
json_reader_read_member(reader, SECTION_ITEMS);
if (!json_reader_is_array(reader)) {
cnt = json_reader_count_elements(reader);
for (i = 0; i < cnt; i++) {
- it = _new_bar_item(reader, i);
+ it = CEngineBarItem::Alloc(reader, i);
if (!it)
continue;
- it->eng = eng;
- eng->hbar_its = eina_list_append(eng->hbar_its, it);
+
+ it->SetEngine(this);
+ m->hbar_its = eina_list_append(m->hbar_its, it);
/* send unique id to each content provider */
cbus = new CClientBus;
_ERR(" Unable to allocate memory for client bus");
continue;
}
- cbus->Create(it->bus_name, it->object_path, it->svcid);
+ cbus->Create(
+ it->Str(CEngineBarItem::VSTR_BUS_NAME),
+ it->Str(CEngineBarItem::VSTR_OBJECT_PATH),
+ it->Str(CEngineBarItem::VSTR_SVC_ID)
+ );
if (!cbus->FlagCreate()) {
_ERR(" Unable to init client bus ");
delete cbus;
continue;
}
cbus->SendSvcid();
- eng->client_buslist = eina_list_append(eng->client_buslist,
+ m->client_buslist = eina_list_append(m->client_buslist,
cbus);
}
json_reader_end_member(reader);
- return 0;
+ return true;
err:
json_reader_end_member(reader);
- return -1;
+ return false;
}
-static inline void _unload_bar_items(struct engine *eng)
+
+void CEngine::_unload_bar_items(void)
{
- struct engine_bar_item *it;
+ CEngineBarItem *it;
void *obj;
- if (!eng || !eng->hbar_its) {
+ if (!m->hbar_its) {
_ERR("Invalid argument");
return;
}
- EINA_LIST_FREE(eng->hbar_its, obj) {
- it = (struct engine_bar_item *)obj;
- _unload_bar_item(it);
+ EINA_LIST_FREE(m->hbar_its, obj) {
+ it = (CEngineBarItem *)obj;
+ delete it;
}
- eng->hbar_its = NULL;
+ m->hbar_its = NULL;
}
-static inline void _unload_ubar_items(struct engine *eng)
+
+void CEngine::_unload_ubar_items(void)
{
- struct engine_ubar_item *it;
+ CEngineUBarItem *it;
void *obj;
- if (!eng || !eng->ubar_its) {
+ if (!m->ubar_its) {
_ERR("Invalid argument");
return;
}
- EINA_LIST_FREE(eng->ubar_its, obj) {
- it = (struct engine_ubar_item *)obj;
- free(it->name);
- free(it->thumb_bg);
- free(it->thumb);
+ EINA_LIST_FREE(m->ubar_its, obj) {
+ it = (CEngineUBarItem *)obj;
+ delete it;
}
- eng->ubar_its = NULL;
+ m->ubar_its = NULL;
}
static JsonParser *_get_parser(const char *config)
{
+ ASSERT(config);
+
JsonParser *parser;
gboolean r;
- if (!config) {
- _ERR("Invalid argument");
- return NULL;
- }
-
parser = json_parser_new();
if (!parser) {
_ERR("json parser new failed");
return parser;
}
-static int _load_item_config(struct engine *eng)
+
+bool CEngine::m_LoadItemConfig(void)
{
JsonParser *parser;
JsonReader *reader;
- if (!eng) {
- _ERR("Invalid argument");
- return -1;
- }
-
- parser = _get_parser(DEF_CONFIG);
- if (!parser) {
- _ERR("json parser new failed");
- return -1;
- }
+ _CREATE_BEGIN{
+ _CHECK(parser = _get_parser(DEF_CONFIG));
+ _CHECK(reader = _get_reader(parser));
+ _CHECK(_load_bar_items(reader));
- reader = _get_reader(parser);
- if (!reader) {
- _ERR("reader get failed");
- goto unref_parser;
- }
-
- if (_load_bar_items(reader, eng) != 0)
- goto unref_reader;
-
- g_object_unref(reader);
- g_object_unref(parser);
-
- return 0;
+ _CHECK_FAIL{ /* _load_bar_items(reader) */ }
+ _CHECK_FAIL{ g_object_unref(reader); }
+ _CHECK_FAIL{ g_object_unref(parser); }
+ } _CREATE_END_AND_CATCH{ return false; }
-unref_reader:
g_object_unref(reader);
-unref_parser:
g_object_unref(parser);
- return -1;
+ return true;
}
-static struct engine_ubar_item *_new_ubar_item(const char *name,
- const char *icon)
-{
- struct engine_ubar_item *it;
- if (!name) {
- _ERR("Invalid user");
- return NULL;
- }
+CEngineUBarItem *CEngineUBarItem::Alloc(CEngine *eng, const char *name, const char *icon)
+{
+ ASSERT(name);
- it = (struct engine_ubar_item *)calloc(1, sizeof(*it));
+ CEngineUBarItem *it;
+ it = new CEngineUBarItem(eng);
if (!it) {
_ERR("calloc failed");
return NULL;
if (!icon || strlen(icon) == 0)
icon = DEF_USER_THUMB;
- it->name = strdup(name);
- it->thumb = strdup(icon);
+ it->SetStr(VSTR_NAME, name);
+ it->SetStr(VSTR_THUMB, icon);
return it;
}
return dest_strv;
}
-static int _load_login_user(struct engine *eng, uid_t uid)
+
+int CEngine::_load_login_user(uid_t uid)
{
GumUser *user;
const char *icon, *name;
struct passwd *passwd;
- if (!eng) {
- _ERR("Invalid argument");
- return -1;
- }
-
user = gum_user_get_sync(uid, FALSE);
if (!user) {
_ERR("failed to get login user");
passwd = getpwuid(uid);
- eng->user.name = strdup(passwd->pw_name ?
- passwd->pw_name : DEF_USER_NAME);
- eng->user.thumb = strdup(DEF_USER_THUMB);
+ m->user.name = strdup(passwd->pw_name ? passwd->pw_name : DEF_USER_NAME);
+ m->user.thumb = strdup(DEF_USER_THUMB);
return -1;
}
if (!icon || strlen(icon) == 0)
icon = DEF_USER_THUMB;
- eng->user.name = strdup(name);
- eng->user.thumb = strdup(icon);
+ m->user.name = strdup(name);
+ m->user.thumb = strdup(icon);
g_object_unref(user);
return 0;
}
-static int _load_user(struct engine *eng)
+
+bool CEngine::m_LoadUser(void)
{
GumUserList *list;
GumUser *user;
gchar **strv;
int i, r;
uid_t user_uid, uid;
- struct engine_ubar_item *it;
+ CEngineUBarItem *it;
const char *icon, *name;
-
- if (!eng) {
- _ERR("Invalid argument");
- return -1;
- }
-
+
user_uid = getuid();
- r = _load_login_user(eng, user_uid);
+ r = _load_login_user(user_uid);
if (r < 0) {
_ERR("failed to load login user");
- return 0;
+ return true;
}
- if (engine_ubar_item_get_privilege(eng)) {
- it = _new_ubar_item(DEF_ADD_NAME, DEF_ADD_THUMB);
+ if (GetPrivilege()) {
+ it = CEngineUBarItem::Alloc(this, DEF_ADD_NAME, DEF_ADD_THUMB);
if (it) {
- it->eng = eng;
- eng->ubar_its = eina_list_append(eng->ubar_its, it);
+ m->ubar_its = eina_list_append(m->ubar_its, it);
}
}
service = gum_user_service_create_sync(FALSE);
if (!service) {
_ERR("failed to create service");
- return -1;
+ return false;
}
strv = _append_string(NULL, "normal");
if (!list) {
g_object_unref(service);
_ERR("failed to get user list");
- return -1;
+ return false;
}
for (i = 0; i < (int)g_list_length(list); i++) {
if (uid == user_uid)
continue;
- it = _new_ubar_item(name, icon);
- if (!it)
- continue;
-
- it->eng = eng;
- eng->ubar_its = eina_list_append(eng->ubar_its, it);
+ it = CEngineUBarItem::Alloc(this, name, icon);
+ if (it)
+ m->ubar_its = eina_list_append(m->ubar_its, it);
}
gum_user_service_list_free(list);
g_object_unref(service);
- return 0;
+ return true;
}
-static void _unload_config(struct engine *eng)
-{
- if (!eng)
- return;
-
- _unload_config_user(eng);
- _unload_bar_items(eng);
- _unload_ubar_items(eng);
-}
-static void _bus_ready(CBaseBus *bus, void *data)
+void CEngine::m_UnloadConfig(void)
{
- bus->SendSignal(BUS_SIGNAL_REFRESH);
+ _unload_config_user();
+ _unload_bar_items();
+ _unload_ubar_items();
}
-static void _bus_end(CBaseBus *bus, void *data)
+void CEngine::sm_CbBusReady(CBaseBus *bus, void *data)
{
+ bus->SendSignal(BUS_SIGNAL_REFRESH);
}
-static inline struct engine_dbar_item_content *_new_ctnt(
- CBus::SContent *bus_ctnt)
+void CEngine::sm_CbBusEnd(CBaseBus *bus, void *data)
{
- struct engine_dbar_item_content *ctnt;
-
- if (!bus_ctnt)
- return NULL;
-
- ctnt = (struct engine_dbar_item_content *)calloc(1, sizeof(*ctnt));
- if (!ctnt) {
- _ERR("calloc failed");
- return NULL;
- }
-
- switch (bus_ctnt->type) {
- case CBus::CONTENT_TYPE_IMAGE:
- ctnt->type = ENGINE_DBAR_CONTENT_TYPE_IMAGE;
- break;
- case CBus::CONTENT_TPPE_VIDEO:
- ctnt->type = ENGINE_DBAR_CONTENT_TYPE_VIDEO;
- break;
- case CBus::CONTENT_TYPE_MUSIC:
- ctnt->type = ENGINE_DBAR_CONTENT_TYPE_MUSIC;
- break;
- case CBus::CONTENT_TYPE_BROADCAST:
- ctnt->type = ENGINE_DBAR_CONTENT_TYPE_BROADCAST;
- break;
- case CBus::CONTENT_TYPE_APP:
- ctnt->type = ENGINE_DBAR_CONTENT_TYPE_APP;
- break;
- case CBus::CONTENT_TYPE_SOURCE:
- ctnt->type = ENGINE_DBAR_CONTENT_TYPE_SOURCE;
- break;
- case CBus::CONTENT_TYPE_NOTIFICATION_NOTI:
- ctnt->type = ENGINE_DBAR_CONTENT_TYPE_NOTIFICATION_NOTI;
- break;
- case CBus::CONTENT_TYPE_NOTIFICATION_ONGOING:
- ctnt->type = ENGINE_DBAR_CONTENT_TYPE_NOTIFICATION_ONGOING;
- break;
- case CBus::CONTENT_TYPE_HISTORY:
- ctnt->type = ENGINE_DBAR_CONTENT_TYPE_HISTORY;
- break;
- default:
- _ERR("Invalid content type");
- free(ctnt);
- return NULL;
- }
-
- if (bus_ctnt->subtitle)
- ctnt->subtitle = strdup(bus_ctnt->subtitle);
- if (bus_ctnt->description)
- ctnt->description = strdup(bus_ctnt->description);
- if (bus_ctnt->detail)
- ctnt->detail = strdup(bus_ctnt->detail);
- if (bus_ctnt->thumbnail)
- ctnt->thumbnail = strdup(bus_ctnt->thumbnail);
- if (bus_ctnt->icon)
- ctnt->icon = strdup(bus_ctnt->icon);
-
- return ctnt;
}
-static inline void _free_ctnt(struct engine_dbar_item_content *ctnt)
-{
- if (!ctnt)
- return;
-
- free(ctnt->subtitle);
- free(ctnt->description);
- free(ctnt->detail);
- free(ctnt->icon);
- free(ctnt->thumbnail);
- free(ctnt);
-}
-static int _add_dbar_item(struct engine_bar_item *hit,
- enum engine_dbar_item_style style,
+static int _add_dbar_item(CEngineBarItem *hit,
+ CEngineDBarItem::EStyle style,
const char *name, CBus::SContent bus_ctnt[],
int ctnt_cnt, CBus::EActionOp action,
const char *actor, const char *args)
{
- struct engine_dbar_item *dit;
- struct engine_dbar_item_content *ctnt;
+ CEngineDBarItem *dit;
+ CEngineDBarItemContent *ctnt;
int i;
if (!hit) {
return -1;
}
- dit = (struct engine_dbar_item *)calloc(1, sizeof(*dit));
+ dit = new CEngineDBarItem(hit);
if (!dit) {
_ERR("calloc failed");
return -1;
}
- dit->name = strdup(name ? name : "No Information");
+ dit->SetStr(CEngineDBarItem::VSTR_NAME, name ? name : "No Information");
if (ctnt_cnt > BUS_DATA_ALBUM_CONTENT_MAX)
ctnt_cnt = BUS_DATA_ALBUM_CONTENT_MAX;
if (bus_ctnt) {
for (i = 0; i < ctnt_cnt; i++) {
- ctnt = _new_ctnt(&bus_ctnt[i]);
+ ctnt = CEngineDBarItemContent::Alloc(&bus_ctnt[i]);
if (!ctnt)
break;
- dit->ctnts = eina_list_append(dit->ctnts, ctnt);
+ dit->AddContent(ctnt);
+
}
}
- dit->ctnt_id = hit->ctnt_id++;
- dit->hit = hit;
- dit->style = style;
- dit->action = action;
- if (actor)
- dit->actor = strdup(actor);
- if (args)
- dit->args = strdup(args);
+ hit->SetCtntId(hit->CtntId() + 1);
+ dit->SetInt(CEngineDBarItem::VINT_CONTENT_ID, hit->CtntId()); //dit->SetCtntId(hit->CtntId());//dit->ctnt_id = hit->ctnt_id++;
+ dit->SetInt(CEngineDBarItem::VINT_STYLE, style); // SetStyle(style);// dit->style = style;
+ dit->SetInt(CEngineDBarItem::VINT_ACTION, action); // dit->SetAction(action);// dit->action = action;
+ dit->SetStr(CEngineDBarItem::VSTR_ACTOR, actor); // dit->SetActor(actor);// if (actor)dit->actor = strdup(actor);
+ dit->SetStr(CEngineDBarItem::VSTR_ARGS, args); // dit->SetArgs(args);// if (args) dit->args = strdup(args);
- hit->dbar_its = eina_list_append(hit->dbar_its, dit);
- if (hit->update_cb)
- hit->update_cb(hit, hit->update_cb_data);
+ hit->AddItem(dit);//hit->dbar_its = eina_list_append(hit->dbar_its, dit);
+ hit->InvokeUpdateCallback();
- return dit->ctnt_id;
+ return dit->Int(CEngineDBarItem::VINT_CONTENT_ID);// dit->CtntId();
}
-static inline void _free_dbar_item(struct engine_dbar_item *dit)
-{
- struct engine_dbar_item_content *ctnt;
- void *obj;
-
- EINA_LIST_FREE(dit->ctnts, obj) {
- ctnt = (struct engine_dbar_item_content *)obj;
- _free_ctnt(ctnt);
- }
-
- free(dit->actor);
- free(dit->args);
- free(dit->name);
- free(dit);
-}
-static int _del_dbar_item(struct engine_bar_item *hit, int ctnt_id)
+static int _del_dbar_item(CEngineBarItem *hit, int ctnt_id)
{
- struct engine_dbar_item *dit;
- Eina_List *l;
- void *obj;
-
if (!hit)
return -1;
- EINA_LIST_FOREACH(hit->dbar_its, l, obj) {
- dit = (struct engine_dbar_item *)obj;
- if (dit->ctnt_id == ctnt_id) {
- hit->dbar_its = eina_list_remove_list(
- hit->dbar_its, l);
- _free_dbar_item(dit);
- if (hit->update_cb)
- hit->update_cb(hit, hit->update_cb_data);
- return 0;
- }
- }
-
- return -1;
+ return hit->RemoveDBar(ctnt_id) ? 0 : -1;
}
-static int _del_dbar_item_all(struct engine_bar_item *hit)
+static int _del_dbar_item_all(CEngineBarItem *hit)
{
- struct engine_dbar_item *dit;
- void *obj;
-
if (!hit)
return -1;
- EINA_LIST_FREE(hit->dbar_its, obj) {
- dit = (struct engine_dbar_item *)obj;
- _free_dbar_item(dit);
- }
- hit->dbar_its = NULL;
-
- if (hit->update_cb)
- hit->update_cb(hit, hit->update_cb_data);
+ hit->RemoveAllDBar();
+ hit->InvokeUpdateCallback();
return 0;
}
-static bool _bus_add_label(CBus::SLabel *lbl, void *data)
+bool CEngine::sm_CbAddLabel(CBus::SLabel *lbl, void *data)
+{
+ CEngine *root = (CEngine*)data;
+ bool ret = false;
+ if (root)
+ ret = root->m_OnAddLabel(lbl);
+ return ret;
+}
+
+
+bool CEngine::m_OnAddLabel(CBus::SLabel *lbl)
{
- struct engine_bar_item *hit;
- struct engine *eng;
+ CEngineBarItem *hit;
Eina_List *l;
void *obj;
- if (!lbl || !data) {
+ if (!lbl) {
_ERR("Invalid argument");
return false;
}
- eng = (struct engine *)data;
- EINA_LIST_FOREACH(eng->hbar_its, l, obj) {
- hit = (struct engine_bar_item *)obj;
- if (strcmp(hit->svcid, lbl->svcid))
+ EINA_LIST_FOREACH(m->hbar_its, l, obj) {
+ hit = (CEngineBarItem *)obj;
+ if (strcmp(hit->Str(CEngineBarItem::VSTR_SVC_ID), lbl->svcid))
continue;
- return _add_dbar_item(hit, ENGINE_DBAR_ITEM_STYLE_LABEL,
+ return _add_dbar_item(hit, CEngineDBarItem::STYLE_LABEL,
lbl->title, NULL, 0,
CBus::ACTION_OP_LAUNCH_NONE,
NULL, NULL);
return false;
}
-static bool _bus_add_album(CBus::SAlbum *album,
- CBus::SAction *act, void *data)
+bool CEngine::sm_CbAddAlbum(CBus::SAlbum *album, CBus::SAction *act, void *data)
+{
+ CEngine *root = (CEngine*)data;
+ bool ret = false;
+ if (root)
+ ret = root->m_OnAddAlbum(album, act);
+ return ret;
+}
+
+
+bool CEngine::m_OnAddAlbum(CBus::SAlbum *album, CBus::SAction *act)
{
- struct engine_bar_item *hit;
- struct engine *eng;
+ CEngineBarItem *hit;
Eina_List *l;
void *obj;
- if (!album || !act || !data) {
+ if (!album || !act) {
_ERR("Invalid argument");
return -1;
}
- eng = (struct engine *)data;
- EINA_LIST_FOREACH(eng->hbar_its, l, obj) {
- hit = (struct engine_bar_item *)obj;
- if (strcmp(hit->svcid, album->svcid))
+ EINA_LIST_FOREACH(m->hbar_its, l, obj) {
+ hit = (CEngineBarItem *)obj;
+ if (strcmp(hit->Str(CEngineBarItem::VSTR_SVC_ID), album->svcid))
continue;
- return _add_dbar_item(hit, ENGINE_DBAR_ITEM_STYLE_ALBUM,
+ return _add_dbar_item(hit, CEngineDBarItem::STYLE_ALBUM,
album->title, album->contents,
album->content_cnt,
act->action,
return -1;
}
-static bool _bus_add_content(CBus::SContent *content,
- CBus::SAction *act, void *data)
+bool CEngine::sm_CbAddContent(CBus::SContent *content, CBus::SAction *act, void *data)
+{
+ CEngine *root = (CEngine*)data;
+ bool ret = false;
+ if (root)
+ ret = root->m_OnAddContent(content, act);
+ return ret;
+}
+
+
+bool CEngine::m_OnAddContent(CBus::SContent *content, CBus::SAction *act)
{
- struct engine_bar_item *hit;
- struct engine *eng;
+ CEngineBarItem *hit;
Eina_List *l;
void *obj;
- if (!content || !act || !data) {
+ if (!content || !act) {
_ERR("Invalid argument");
return -1;
}
- eng = (struct engine *)data;
- EINA_LIST_FOREACH(eng->hbar_its, l, obj) {
- hit = (struct engine_bar_item *)obj;
- if (strcmp(hit->svcid, content->svcid))
+ EINA_LIST_FOREACH(m->hbar_its, l, obj) {
+ hit = (CEngineBarItem *)obj;
+ if (strcmp(hit->Str(CEngineBarItem::VSTR_SVC_ID), content->svcid))
continue;
- return _add_dbar_item(hit, ENGINE_DBAR_ITEM_STYLE_CONTENT,
+ return _add_dbar_item(hit, CEngineDBarItem::STYLE_CONTENT,
content->title, content, 1,
act->action,
act->actor,
}
static void _get_item_bg_and_icon(enum CBus::EPinType type, const char *icon,
- struct engine_bar_item *it)
+ CEngineBarItem *it)
{
switch (type) {
case CBus::PIN_TYPE_CHANNEL:
- it->r = ITEM_CHANNEL_BG_R;
- it->g = ITEM_CHANNEL_BG_G;
- it->b = ITEM_CHANNEL_BG_B;
- it->icon = strdup(DEF_PIN_ITEM_CHANNEL_ICON);
- it->icon_focus = strdup(DEF_PIN_ITEM_CHANNEL_ICON_FOCUS);
- it->type = CAppContentFavorite::TYPE_CHANNEL;
+ it->SetColor(ITEM_CHANNEL_BG_R, ITEM_CHANNEL_BG_G, ITEM_CHANNEL_BG_B);
+ it->SetType(CAppContentFavorite::TYPE_CHANNEL);
+
+ it->SetStr(CEngineBarItem::VSTR_ICON, DEF_PIN_ITEM_CHANNEL_ICON);
+ it->SetStr(CEngineBarItem::VSTR_ICON_FOCUS, DEF_PIN_ITEM_CHANNEL_ICON_FOCUS);
break;
case CBus::PIN_TYPE_PACKAGE:
- it->r = ITEM_PACKAGE_BG_R;
- it->g = ITEM_PACKAGE_BG_G;
- it->b = ITEM_PACKAGE_BG_B;
+ it->SetColor(ITEM_PACKAGE_BG_R, ITEM_PACKAGE_BG_G, ITEM_PACKAGE_BG_B);
if (icon) {
- it->icon = strdup(icon);
- it->icon_focus = strdup(icon);
+ it->SetStr(CEngineBarItem::VSTR_ICON, icon);
+ it->SetStr(CEngineBarItem::VSTR_ICON_FOCUS, icon);
} else {
- it->icon = strdup(DEF_PIN_ITEM_DEFAULT_ICON);
- it->icon_focus =
- strdup(DEF_PIN_ITEM_DEFAULT_ICON_FOCUS);
+ it->SetStr(CEngineBarItem::VSTR_ICON, DEF_PIN_ITEM_DEFAULT_ICON);
+ it->SetStr(CEngineBarItem::VSTR_ICON_FOCUS, DEF_PIN_ITEM_DEFAULT_ICON_FOCUS);
}
- it->type = CAppContentFavorite::TYPE_APPS;
+ it->SetType(CAppContentFavorite::TYPE_APPS);
break;
default:
- it->r = ITEM_DEFAULT_BG_R;
- it->g = ITEM_DEFAULT_BG_G;
- it->b = ITEM_DEFAULT_BG_B;
- it->icon = strdup(DEF_PIN_ITEM_DEFAULT_ICON);
- it->icon_focus = strdup(DEF_PIN_ITEM_DEFAULT_ICON_FOCUS);
+ it->SetColor(ITEM_DEFAULT_BG_R, ITEM_DEFAULT_BG_G, ITEM_DEFAULT_BG_B);
+ it->SetStr(CEngineBarItem::VSTR_ICON, DEF_PIN_ITEM_DEFAULT_ICON);
+ it->SetStr(CEngineBarItem::VSTR_ICON_FOCUS, DEF_PIN_ITEM_DEFAULT_ICON_FOCUS);
break;
}
}
-static struct engine_bar_item *_new_pin_item(struct engine *eng,
- const char *title, enum CBus::EPinType type,
+
+CEngineBarItem *CEngineBarItem::Alloc(const char *title, CBus::EPinType type,
const char *icon, const char *svcid,
- enum CBus::EActionOp action, const char *actor,
+ CBus::EActionOp action, const char *actor,
const char *args, const char *pinid)
{
- struct engine_bar_item *it;
+ CEngineBarItem *it;
if (!title || !svcid || type > CBus::PIN_TYPE_MAX || !pinid)
return NULL;
- it = (struct engine_bar_item *)calloc(1, sizeof(*it));
+ it = new CEngineBarItem;
if (!it) {
_ERR("calloc failed");
return NULL;
}
- it->name = strdup(title);
- it->svcid = strdup(svcid);
- it->in = strdup("custombar");
- it->is_pinned = EINA_TRUE;
- it->ctnt_id++;
- it->pinid = strdup(pinid);
+ it->SetIsPinned(EINA_TRUE);
+ it->SetCtntId(it->CtntId() + 1);
+
+ it->SetStr(CEngineBarItem::VSTR_NAME, title);
+ it->SetStr(CEngineBarItem::VSTR_SVC_ID, svcid);
+ it->SetStr(CEngineBarItem::VSTR_IN, "custombar");
+ it->SetStr(CEngineBarItem::VSTR_PIN_ID, pinid);
_get_item_bg_and_icon(type, icon, it);
if (action == CBus::ACTION_OP_LAUNCH_APP)
- it->app = strdup(actor);
+ it->SetStr(CEngineBarItem::VSTR_APP, actor);// SetApp(actor);
if (args)
- it->args = strdup(args);
+ it->SetStr(CEngineBarItem::VSTR_ARGS, args);// SetArgs(args);
return it;
}
-static void _update_pin_list(struct engine *eng)
+
+void CEngine::_update_pin_list(void)
{
GList *cp_list;
Eina_List *l;
- struct engine_bar_item *hit;
+ CEngineBarItem *hit;
int i;
const char *pinid;
void *obj;
- if (!eng) {
- _ERR("Invalid argument");
- return;
- }
-
cp_list = CAppContentFavorite::List(CAppContentFavorite::OP_PIN);
if (!cp_list) {
_ERR("failed to get pin list");
if (!pinid)
continue;
- EINA_LIST_FOREACH(eng->pin_its, l, obj) {
- hit = (struct engine_bar_item *)obj;
- if (!strcmp(hit->pinid, pinid))
- eng->hbar_its = eina_list_append(eng->hbar_its,
+ EINA_LIST_FOREACH(m->pin_its, l, obj) {
+ hit = (CEngineBarItem *)obj;
+ if (!strcmp(hit->Str(CEngineBarItem::VSTR_PIN_ID), pinid))
+ m->hbar_its = eina_list_append(m->hbar_its,
hit);
}
}
- eng->is_full = EINA_TRUE;
+ m->is_full = EINA_TRUE;
}
-static void _unload_pin_item(struct engine_bar_item *it)
-{
- if (!it)
- return;
-
- free(it->name);
- free(it->icon);
- free(it->icon_focus);
- free(it->svcid);
- free(it->app);
- free(it->args);
- free(it->in);
- free(it->pinid);
- free(it);
-}
-static int _del_pin_item(struct engine *eng, Eina_Bool free)
+int CEngine::_del_pin_item(Eina_Bool free)
{
- struct engine_bar_item *hit;
+ CEngineBarItem *hit;
Eina_List *l;
void *obj;
- if (!eng || !eng->hbar_its)
+ if (!m->hbar_its)
return -1;
- EINA_LIST_FOREACH(eng->hbar_its, l, obj) {
- hit = (struct engine_bar_item *)obj;
- if (!hit->is_pinned)
+ EINA_LIST_FOREACH(m->hbar_its, l, obj) {
+ hit = (CEngineBarItem *)obj;
+ if (!hit->IsPinned())
continue;
- eng->hbar_its = eina_list_remove_list(eng->hbar_its, l);
+ m->hbar_its = eina_list_remove_list(m->hbar_its, l);
if (free)
- _unload_pin_item(hit);
+ delete hit;
}
return 0;
}
-static bool _bus_add_pin(CBus::SPin *pin,
- CBus::SAction *act, void *data)
+bool CEngine::sm_CbAddPin(CBus::SPin *pin, CBus::SAction *act, void *data)
+{
+ CEngine *root = (CEngine*)data;
+ bool ret = false;
+ if (root)
+ ret = root->m_OnAddPin(pin, act);
+ return ret;
+}
+
+
+bool CEngine::m_OnAddPin(CBus::SPin *pin, CBus::SAction *act)
{
- struct engine_bar_item *hit;
- struct engine *eng;
+ CEngineBarItem *hit;
Eina_List *l;
int cnt;
int r;
void *obj;
- if (!pin || !act || !data) {
+ if (!pin || !act) {
_ERR("Invalid argument");
- return -1;
+ return false;
}
- eng = (struct engine *)data;
-
- r = _del_pin_item(eng, EINA_TRUE);
+ r = _del_pin_item(EINA_TRUE);
if (r < 0) {
_ERR("failed to delete pin item in hbar list");
- return -1;
+ return false;
}
- if (eng->is_full) {
- EINA_LIST_FOREACH(eng->pin_its, l, obj) {
- hit = (struct engine_bar_item *)obj;
- eng->pin_its = eina_list_remove_list(eng->pin_its, l);
+ if (m->is_full) {
+ EINA_LIST_FOREACH(m->pin_its, l, obj) {
+ hit = (CEngineBarItem *)obj;
+ m->pin_its = eina_list_remove_list(m->pin_its, l);
}
- eng->is_full = EINA_FALSE;
+ m->is_full = EINA_FALSE;
}
- hit = _new_pin_item(eng, pin->title, pin->type, pin->icon, pin->svcid,
+ hit = CEngineBarItem::Alloc(pin->title, pin->type, pin->icon, pin->svcid,
act->action, act->actor, act->args, pin->pinid);
if (!hit)
- return -1;
+ return false;
- eng->pin_its = eina_list_append(eng->pin_its, hit);
- cnt = eina_list_count(eng->pin_its);
+ m->pin_its = eina_list_append(m->pin_its, hit);
+ cnt = eina_list_count(m->pin_its);
if (engine_bar_item_get_pin_count() != cnt)
- return hit->ctnt_id;
+ return hit->CtntId();
- _update_pin_list(eng);
+ _update_pin_list();
- if (eng->update_cb)
- eng->update_cb(eng->update_cb_data, true);
+ InvokeUpdateCallback();
- return hit->ctnt_id;
+ return hit->CtntId();
}
-/*
-static int _bus_add_ctnt(enum bus_op op, void *opdata, struct SAction *act, void *data)
+
+bool CEngine::sm_CbDelContent(const char *svcid, int ctnt_id, void *data)
{
- switch (op) {
- case BUS_OP_ADD_LABEL:
- return _bus_add_label((SAlbum *)opdata, data);
- case BUS_OP_ADD_ALBUM:
- return _bus_add_album((SAlbum *)opdata, act,
- data);
- case BUS_OP_ADD_CONTENT:
- return _bus_add_content((SContent *)opdata, act,
- data);
- case BUS_OP_ADD_PIN:
- return _bus_add_pin((SPin *)opdata, act, data);
- default:
- _ERR("Operation not supported");
- break;
- }
+ CEngine *root = (CEngine*)data;
+ bool ret = false;
+ if (root)
+ ret = root->m_OnDelContent(svcid, ctnt_id);
+ return ret;
+}
- return -1;
-}*/
-static bool _bus_del_ctnt(const char *svcid, int ctnt_id,
- void *data)
+bool CEngine::m_OnDelContent(const char *svcid, int ctnt_id)
{
- struct engine_bar_item *hit;
- struct engine *eng;
+ CEngineBarItem *hit;
Eina_List *l;
void *obj;
- if (!data || !svcid || ctnt_id < 0) {
+ if (!svcid || ctnt_id < 0) {
_ERR("Invalid argument");
return false;
}
- eng = (struct engine *)data;
- EINA_LIST_FOREACH(eng->hbar_its, l, obj) {
- hit = (struct engine_bar_item *)obj;
- if (strcmp(hit->svcid, svcid))
+ EINA_LIST_FOREACH(m->hbar_its, l, obj) {
+ hit = (CEngineBarItem *)obj;
+ if (strcmp(hit->Str(CEngineBarItem::VSTR_SVC_ID), svcid))
continue;
return _del_dbar_item(hit, ctnt_id);
}
return false;
}
-static bool _bus_del_ctnt_all(const char *svcid, bool reload,
- void *data)
+bool CEngine::sm_CbDelAll(const char *svcid, bool reload, void *data)
+{
+ CEngine *root = (CEngine*)data;
+ bool ret = false;
+ if (root)
+ ret = root->m_OnDelAll(svcid, reload);
+ return ret;
+}
+
+
+bool CEngine::m_OnDelAll(const char *svcid, bool reload)
{
- struct engine_bar_item *hit;
- struct engine *eng;
+ CEngineBarItem *hit;
Eina_List *l;
void *obj;
- if (!data || !svcid) {
+ if (!svcid) {
_ERR("Invalid argument");
return false;
}
- eng = (struct engine *)data;
-
if (reload) {
- _del_pin_item(eng, EINA_TRUE);
- if (eng->update_cb)
- eng->update_cb(eng->update_cb_data, true);
+ _del_pin_item(EINA_TRUE);
+
+ InvokeUpdateCallback();
return true;
}
- EINA_LIST_FOREACH(eng->hbar_its, l, obj) {
- hit = (struct engine_bar_item *)obj;
- if (strcmp(hit->svcid, svcid))
+ EINA_LIST_FOREACH(m->hbar_its, l, obj) {
+ hit = (CEngineBarItem *)obj;
+ if (strcmp(hit->Str(CEngineBarItem::VSTR_SVC_ID), svcid))
continue;
return _del_dbar_item_all(hit);
}
return false;
}
-struct engine *engine_init(void)
+
+bool CEngine::Create(void)
{
- struct engine *eng;
- CBus *bus;
- int r;
+ ASSERT(!m);
CBus::SCallback cb;
- cb.cbReady = _bus_ready;
- cb.cbEnd = _bus_end;
-
- cb.cbAddLabel = _bus_add_label;
- cb.cbAddAlbum = _bus_add_album;
- cb.cbAddContent = _bus_add_content;
- cb.cbAddPin = _bus_add_pin;
+ cb.cbReady = sm_CbBusReady;
+ cb.cbEnd = sm_CbBusEnd;
+
+ cb.cbAddLabel = sm_CbAddLabel;
+ cb.cbAddAlbum = sm_CbAddAlbum;
+ cb.cbAddContent = sm_CbAddContent;
+ cb.cbAddPin = sm_CbAddPin;
+
+ cb.cbDelContent = sm_CbDelContent;
+ cb.cbDelAll = sm_CbDelAll;
+ cb.cookie = this;
+
+ _CREATE_BEGIN{
+ _CHECK(m = new SEngine);
+ _CHECK(m_LoadUser());
+ _CHECK(m_LoadItemConfig());
+ _CHECK(m->bus = new CBus);
+ _CHECK(m->bus->Create(&cb));
+
+ _CHECK_FAIL{ m->bus->Destroy(); }
+ _CHECK_FAIL{ delete m->bus; }
+ _CHECK_FAIL{ m_UnloadConfig(); }
+ _CHECK_FAIL{ /* m_LOadUser */ }
+ _CHECK_FAIL{ delete m; m = NULL; }
+ } _CREATE_END_AND_CATCH{ return false; }
- cb.cbDelContent = _bus_del_ctnt;
- cb.cbDelAll = _bus_del_ctnt_all;
-
- eng = (struct engine *)calloc(1, sizeof(*eng));
- if (!eng) {
- _ERR("calloc failed");
- return NULL;
- }
- cb.cookie = eng;
-
- r = _load_user(eng);
- if (r != 0) {
- free(eng);
- return NULL;
- }
-
- r = _load_item_config(eng);
- if (r != 0) {
- free(eng);
- return NULL;
- }
-
- bus = new CBus;
- if (!bus) {
- _unload_config(eng);
- free(eng);
- return NULL;
- }
- bus->Create(&cb);
- if (!bus) {
- delete bus;
- _unload_config(eng);
- free(eng);
- return NULL;
- }
-
- eng->bus = bus;
-
- return eng;
+ return true;
}
-void engine_fini(struct engine *eng)
+void CEngine::Destroy(void)
{
+ ASSERT(m);
+
CClientBus *cbus;
void *obj;
- if (!eng) {
- _ERR("Invalid argument");
- return;
- }
-
- _unload_config(eng);
- eng->bus->Destroy();
- delete eng->bus;
- EINA_LIST_FREE(eng->client_buslist, obj) {
+ m_UnloadConfig();
+ m->bus->Destroy();
+ delete m->bus;
+ EINA_LIST_FREE(m->client_buslist, obj) {
cbus = (CClientBus *)obj;
cbus->Destroy();
delete cbus;
}
- free(eng);
+ delete m;
+ m = NULL;
}
-int engine_get_user_info(struct engine *eng, const char **name,
- const char **thumb_bg, const char **thumb)
+
+bool CEngine::GetUserInfo(const char **name, const char **thumb_bg, const char **thumb)
{
- if (!eng) {
- _ERR("Invalid argument");
- return -1;
- }
+ ASSERT(m);
if (name)
- *name = eng->user.name;
+ *name = m->user.name;
if (thumb_bg)
- *thumb_bg = eng->user.thumb_bg;
+ *thumb_bg = m->user.thumb_bg;
if (thumb)
- *thumb = eng->user.thumb;
+ *thumb = m->user.thumb;
- return 0;
+ return true;
}
-const Eina_List *engine_get_bar_items(struct engine *eng)
+
+const Eina_List *CEngine::BarItemsList(void)
{
- if (!eng) {
- _ERR("Invalid argument");
- return NULL;
- }
+ ASSERT(m);
- return eng->hbar_its;
+ return m->hbar_its;
}
-const char *engine_bar_item_get_name(struct engine_bar_item *it)
-{
- if (!it)
- return NULL;
-
- return it->name;
-}
-const char *engine_bar_item_get_icon(struct engine_bar_item *it)
-{
- if (!it)
- return NULL;
- return it->icon;
-}
-const char *engine_bar_item_get_icon_focus(struct engine_bar_item *it)
+void CEngine::SetUpdateCallback(void (*update_cb)(void *data, bool focus), void *data)
{
- if (!it)
- return NULL;
+ ASSERT(m);
- return it->icon_focus;
+ m->update_cb = update_cb;
+ m->update_cb_data = data;
}
-const char *engine_bar_item_get_svcid(struct engine_bar_item *it)
-{
- if (!it)
- return NULL;
- return it->svcid;
-}
-
-const char *engine_bar_item_get_bus_name(struct engine_bar_item *it)
+void CEngine::InvokeUpdateCallback(void)
{
- if (!it)
- return NULL;
+ ASSERT(m);
- return it->bus_name;
+ if (m->update_cb)
+ m->update_cb(m->update_cb_data, true);
}
-const char *engine_bar_item_get_object_path(struct engine_bar_item *it)
-{
- if (!it)
- return NULL;
-
- return it->object_path;
-}
-
-const char *engine_bar_item_get_noctnt_title(struct engine_bar_item *it)
-{
- if (!it)
- return NULL;
-
- return it->noctnt_title;
-}
-
-const char *engine_bar_item_get_noctnt_desc(struct engine_bar_item *it)
-{
- if (!it)
- return NULL;
-
- return it->noctnt_desc;
-}
-
-int engine_bar_item_get_color(struct engine_bar_item *it,
- int *r, int *g, int *b)
-{
- if (!it || !r || !g || !b)
- return -1;
-
- *r = it->r;
- *g = it->g;
- *b = it->b;
-
- return 0;
-}
-
-int engine_bar_item_get_content_column(struct engine_bar_item *it,
- int *content_column)
-{
- if (!it || !content_column)
- return -1;
-
- *content_column = it->content_column;
-
- return 0;
-}
-
-int engine_bar_item_launch(struct engine_bar_item *it)
-{
- int r;
- bundle *args;
-
- if (!it)
- return -1;
-
- if (!it->app) {
- _ERR("Application name is not found");
- return -1;
- }
-
- if (it->args)
- args = bundle_decode((const bundle_raw*)it->args,
- strlen(it->args));
- else
- args = NULL;
-
- r = aul_launch_app(it->app, args);
- if (args)
- bundle_free(args);
- if (r < 0) {
- _ERR("Open app failed");
- if (args)
- bundle_free(args);
- return -1;
- }
-
- if (!strcmp(it->app, PACKAGE_LIVE_TV))
- return 0;
-
- r = CAppContentHistory::Add(CAppContentHistory::TYPE_APPS, it->app);
- if (r < 0) {
- _ERR("failed to add history");
- return -1;
- }
-
- return 0;
-}
-
-void engine_bar_item_set_update_cb(struct engine_bar_item *it,
- void (*update_cb)(struct engine_bar_item *it, void *data),
- void *data)
-{
- if (!it)
- return;
-
- it->update_cb = update_cb;
- it->update_cb_data = data;
-}
-
-void engine_bar_item_set_pin_update_cb(struct engine *eng,
- void (*update_cb)(void *data, bool focus),
- void *data)
-{
- if (!eng)
- return;
-
- eng->update_cb = update_cb;
- eng->update_cb_data = data;
-}
-
-bool engine_ubar_item_is_password(struct engine_ubar_item *it,
- const char *password)
-{
- GumUser *user;
- const char *_password;
- bool r;
-
- if (!it || !password) {
- _ERR("Invalid argument");
- return false;
- }
-
- r = false;
- user = gum_user_get_by_name_sync(it->name, FALSE);
- if (!user) {
- _ERR("failed to get user");
- return false;
- }
-
- g_object_get(G_OBJECT(user), GUM_ATTR_PASSWORD, &_password, NULL);
-
- if (!strcmp(password, _password))
- r = true;
-
- g_object_unref(user);
-
- return r;
-}
-int engine_ubar_item_get_info(struct engine_ubar_item *it, const char **name,
- const char **thumb_bg, const char **thumb, int *age)
+bool CEngine::GetPrivilege(void)
{
- if (!it) {
- _ERR("Invalid argument");
- return -1;
- }
-
- if (name)
- *name = it->name;
- if (thumb_bg)
- *thumb_bg = it->thumb_bg;
- if (thumb)
- *thumb = it->thumb;
- if (age)
- *age = it->age;
-
- return 0;
-}
+ ASSERT(m);
-bool engine_ubar_item_get_privilege(struct engine *eng)
-{
int r;
cynara *p_cynara;
- if (!eng) {
- _ERR("Invald argument");
- return false;
- }
-
p_cynara = NULL;
r = cynara_initialize(&p_cynara, NULL);
if (r != CYNARA_API_SUCCESS || !p_cynara) {
return false;
}
- r = cynara_check(p_cynara, "User", "", eng->user.name,
+ r = cynara_check(p_cynara, "User", "", m->user.name,
"user_label.write");
if (r != CYNARA_API_ACCESS_ALLOWED) {
_ERR("cyana denied, %d", r);
return true;
}
-bool engine_ubar_item_delete(struct engine *eng, struct engine_ubar_item *it,
- const char *password)
+bool CEngine::Delete(CEngineUBarItem *it, const char *password)
{
+ ASSERT(m);
+
Eina_List *l;
GumUser *user;
gboolean r;
- struct engine_ubar_item *_it;
+ CEngineUBarItem *_it;
void *obj;
- if (!it || !eng || !password) {
+ if (!it || !password) {
_ERR("Invalid argument");
return false;
}
- user = gum_user_get_by_name_sync(it->name, FALSE);
+ user = gum_user_get_by_name_sync(it->Str(CEngineUBarItem::VSTR_NAME), FALSE);
if (!user) {
_ERR("failed to get user");
return false;
return false;
}
- EINA_LIST_FOREACH(eng->ubar_its, l, obj) {
- _it = (struct engine_ubar_item *)obj;
- if (strcmp(_it->name, it->name))
+ EINA_LIST_FOREACH(m->ubar_its, l, obj) {
+ _it = (CEngineUBarItem *)obj;
+ if (strcmp(_it->Str(CEngineUBarItem::VSTR_NAME), it->Str(CEngineUBarItem::VSTR_NAME)))
continue;
- eng->ubar_its = eina_list_remove_list(eng->ubar_its, l);
+ m->ubar_its = eina_list_remove_list(m->ubar_its, l);
free(_it);
}
return true;
}
-bool engine_ubar_item_update(struct engine *eng, struct engine_ubar_item *it,
- const char *icon, const char *password)
-{
- GumUser *user;
- gboolean r;
-
- if (!eng || !it || !icon || !password) {
- _ERR("Invalid argument");
- return false;
- }
-
- user = gum_user_get_by_name_sync(it->name, FALSE);
- if (!user) {
- _ERR("failed to get user");
- return false;
- }
-
- g_object_set(G_OBJECT(user), GUM_ATTR_PASSWORD, password,
- GUM_ATTR_ICON, icon, NULL);
-
- r = gum_user_update_sync(user);
- if (!r) {
- _ERR("failed to update user");
- g_object_unref(user);
- return false;
- }
- it->thumb = strdup(icon);
-
- g_object_unref(user);
-
- return true;
-}
-
-bool engine_ubar_item_change_user(struct engine *eng,
- struct engine_ubar_item *it, const char *password)
+const Eina_List *CEngine::UBarItemsList(void)
{
- int r;
-
- if (!eng || !it || !password) {
- _ERR("Invalid argument");
- return false;
- }
+ ASSERT(m);
- r = bus_change_user(it->name, password);
- if (r < 0) {
- _ERR("failed to switch user");
- return false;
- }
-
- elm_exit();
-
- return true;
+ return m->ubar_its;
}
-bool engine_ubar_item_add(struct engine *eng, const char *name,
- const char *password, const char *icon)
+
+bool CEngine::DelPin(CEngineBarItem *it)
{
- struct engine_ubar_item *item;
- GumUser *user;
- gboolean r;
+ ASSERT(m);
- if (!eng || !name || !password || !icon) {
- _ERR("Invalid argument");
- return false;
- }
+ Eina_List *l;
+ CEngineBarItem *hit;
+ int r, cnt;
+ void *obj;
- user = gum_user_create_sync(FALSE);
- if (!user) {
- _ERR("failed to get user");
+ if (!it)
return false;
- }
-
- g_object_set(G_OBJECT(user), GUM_ATTR_NAME, name,
- GUM_ATTR_PASSWORD, password,
- GUM_ATTR_USERTYPE, GUM_USERTYPE_NORMAL,
- GUM_ATTR_ICON, icon, NULL);
- r = gum_user_add_sync(user);
- if (!r) {
- _ERR("failed to add user");
- g_object_unref(user);
+ r = CAppContentFavorite::Unset(CAppContentFavorite::OP_PIN, it->Type(), it->Str(CEngineBarItem::VSTR_PIN_ID));
+ if (r < 0) {
+ _ERR("failed to unset pin item");
return false;
}
- item = _new_ubar_item(name, icon);
- eng->ubar_its = eina_list_append(eng->ubar_its, item);
-
- g_object_unref(user);
-
- return true;
-}
-
-const Eina_List *engine_get_ubar_items(struct engine *eng)
-{
- if (!eng) {
- _ERR("invalid argument");
- return NULL;
- }
+ cnt = CAppContentFavorite::Count(CAppContentFavorite::OP_PIN);
+ if (cnt != 0)
+ return true;
- return eng->ubar_its;
-}
+ EINA_LIST_FOREACH(m->hbar_its, l, obj) {
+ hit = (CEngineBarItem *)obj;
+ if (!hit->Str(CEngineBarItem::VSTR_PIN_ID))
+ continue;
-const Eina_List *engine_get_dbar_items(struct engine_bar_item *it)
-{
- if (!it) {
- _ERR("Invalid argument");
- return NULL;
+ if (!strcmp(hit->Str(CEngineBarItem::VSTR_PIN_ID), it->Str(CEngineBarItem::VSTR_PIN_ID))) {
+ m->hbar_its = eina_list_remove_list(m->hbar_its, l);
+ delete hit;
+ break;
+ }
}
- return it->dbar_its;
+ return true;
}
-const Eina_List *engine_dbar_item_get_contents(struct engine_dbar_item *it)
-{
- if (!it) {
- _ERR("Invalid argument");
- return NULL;
- }
-
- return it->ctnts;
-}
-const char *engine_dbar_item_get_name(struct engine_dbar_item *it)
+void CEngine::AddUBar(CEngineUBarItem *it)
{
- if (!it) {
- _ERR("Invalid argument");
- return NULL;
- }
+ ASSERT(m);
- return it->name;
+ m->ubar_its = eina_list_append(m->ubar_its, it);
}
-enum engine_dbar_item_style engine_dbar_item_get_style(
- struct engine_dbar_item *it)
-{
- if (!it) {
- _ERR("Invalid argument");
- return ENGINE_DBAR_ITEM_STYLE_CONTENT;
- }
-
- return it->style;
-}
-int engine_dbar_item_get_color(struct engine_dbar_item *it,
- int *r, int *g, int *b)
+bool CEngine::Swap(CEngineBarItem *it1, CEngineBarItem *it2)
{
- if (!it || !r || !g || !b) {
- _ERR("Invalid argument");
- return -1;
- }
+ ASSERT(it1);
+ ASSERT(it2);
- return engine_bar_item_get_color(it->hit, r, g, b);
-}
-
-static inline int _launch_app(struct engine_dbar_item *it)
-{
int r;
- bundle *args;
- struct engine_dbar_item_content *ctnt;
-
- if (!it)
- return -1;
- if (it->args)
- args = bundle_decode((const bundle_raw*)it->args,
- strlen(it->args));
- else
- args = NULL;
-
- r = aul_launch_app(it->actor, args);
- if (args)
- bundle_free(args);
- if (r < 0) {
- _ERR("launch app failed");
- return -1;
- }
-
- ctnt = (struct engine_dbar_item_content *)
- eina_list_data_get(it->ctnts);
- if (!ctnt) {
- _ERR("get ctnt failed");
- return 0;
+ if (!it1->Str(CEngineBarItem::VSTR_PIN_ID) || !it2->Str(CEngineBarItem::VSTR_PIN_ID)) {
+ _ERR("No pin item");
+ return false;
}
- if ((ctnt->type == ENGINE_DBAR_CONTENT_TYPE_BROADCAST) ||
- !strcmp(it->actor, PACKAGE_LIVE_TV))
- return 0;
-
- r = CAppContentHistory::Add(CAppContentHistory::TYPE_APPS, it->actor);
+ r = CAppContentFavorite::Swap(CAppContentFavorite::OP_PIN,
+ it1->Type(), it1->Str(CEngineBarItem::VSTR_PIN_ID),
+ it2->Type(), it2->Str(CEngineBarItem::VSTR_PIN_ID));
if (r < 0) {
- _ERR("failed to add history");
- return 0;
- }
-
- return 0;
-}
-
-int engine_dbar_item_launch(struct engine_dbar_item *it)
-{
- if (!it)
- return -1;
-
- switch (it->action) {
- case CBus::ACTION_OP_LAUNCH_NONE:
- _ERR("Non-launchable item");
- break;
- case CBus::ACTION_OP_LAUNCH_APP:
- return _launch_app(it);
- case CBus::ACTION_OP_LAUNCH_SERVICE:
- _ERR("Service launching is not supported yet");
- break;
- default:
- _ERR("Invalid action type");
- break;
- }
-
- return 0;
-}
-
-enum engine_dbar_content_type engine_dbar_item_get_content_type(
- struct engine_dbar_item_content *ctnt)
-{
- if (!ctnt) {
- _ERR("Invalid argument");
- return ENGINE_DBAR_CONTENT_TYPE_IMAGE;
- }
-
- return ctnt->type;
-}
-
-const char *engine_dbar_item_get_content_subtitle(
- struct engine_dbar_item_content *ctnt)
-{
- if (!ctnt) {
- _ERR("Invalid argument");
- return NULL;
- }
-
- return ctnt->subtitle;
-}
-
-const char *engine_dbar_item_get_content_description(
- struct engine_dbar_item_content *ctnt)
-{
- if (!ctnt) {
- _ERR("Invalid argument");
- return NULL;
- }
-
- return ctnt->description;
-}
-
-const char *engine_dbar_item_get_content_detail(
- struct engine_dbar_item_content *ctnt)
-{
- if (!ctnt) {
- _ERR("Invalid argument");
- return NULL;
- }
-
- return ctnt->detail;
-}
-
-const char *engine_dbar_item_get_content_thumbnail(
- struct engine_dbar_item_content *ctnt)
-{
- if (!ctnt) {
- _ERR("Invalid argument");
- return NULL;
- }
-
- return ctnt->thumbnail;
-}
-
-const char *engine_dbar_item_get_content_icon(
- struct engine_dbar_item_content *ctnt)
-{
- if (!ctnt) {
- _ERR("Invalid argument");
- return NULL;
+ _ERR("failed to swap pin item");
+ return false;
}
- return ctnt->icon;
-}
-
-const char *engine_bar_item_get_in(struct engine_bar_item *it)
-{
- if (!it)
- return NULL;
-
- return it->in;
-}
-
-const char *engine_dbar_item_get_in(struct engine_dbar_item *it)
-{
- if (!it)
- return NULL;
+ _del_pin_item(EINA_FALSE);
+ _update_pin_list();
- return engine_bar_item_get_in(it->hit);
-}
-
-Eina_Bool engine_bar_item_get_is_pinned(struct engine_bar_item *it)
-{
- if (!it)
- return EINA_FALSE;
-
- return it->is_pinned;
+ return true;
}
-int engine_bar_item_del_pin(struct engine *eng, struct engine_bar_item *it)
-{
- Eina_List *l;
- struct engine_bar_item *hit;
- int r, cnt;
- void *obj;
-
- if (!it || !eng)
- return -1;
-
- r = CAppContentFavorite::Unset(CAppContentFavorite::OP_PIN, it->type, it->pinid);
- if (r < 0) {
- _ERR("failed to unset pin item");
- return -1;
- }
-
- cnt = CAppContentFavorite::Count(CAppContentFavorite::OP_PIN);
- if (cnt != 0)
- return 0;
-
- EINA_LIST_FOREACH(eng->hbar_its, l, obj) {
- hit = (struct engine_bar_item *)obj;
- if (!hit->pinid)
- continue;
-
- if (!strcmp(hit->pinid, it->pinid)) {
- eng->hbar_its = eina_list_remove_list(eng->hbar_its, l);
- _unload_pin_item(hit);
- break;
- }
- }
-
- return 0;
-}
int engine_bar_item_get_pin_count(void)
{
return r;
}
-int engine_bar_item_swap_pin(struct engine *eng, struct engine_bar_item *it1,
- struct engine_bar_item *it2)
-{
- int r;
-
- if (!eng || !it1 || !it2) {
- _ERR("Invalid argument");
- return -1;
- }
-
- if (!it1->pinid || !it2->pinid) {
- _ERR("No pin item");
- return -1;
- }
-
- r = CAppContentFavorite::Swap(CAppContentFavorite::OP_PIN, it1->type, it1->pinid,
- it2->type, it2->pinid);
- if (r < 0) {
- _ERR("failed to swap pin item");
- return -1;
- }
-
- _del_pin_item(eng, EINA_FALSE);
- _update_pin_list(eng);
-
- return 0;
-}
-int engine_dbar_item_del(struct engine_dbar_item *it,
- enum engine_dbar_content_type type)
+int engine_dbar_item_del_all(enum CEngineDBarItemContent::EType type)
{
- bundle *args;
- const char *svcid;
- int r;
-
- if (!it || !it->actor || type > ENGINE_DBAR_CONTENT_TYPE_MAX) {
- _ERR("Invalid argument");
- return -1;
- }
+ ASSERT(0 <= type && type <= CEngineDBarItemContent::TYPE_MAX);
- switch (type) {
- case ENGINE_DBAR_CONTENT_TYPE_HISTORY:
- if (!strcmp(it->actor, PACKAGE_LIVE_TV)) {
- if (!it->args)
- return -1;
-
- args = bundle_decode((const bundle_raw*)it->args,
- strlen(it->args));
- if (!args) {
- _ERR("failed to decode bundle");
- return -1;
- }
-
- svcid = bundle_get_val(args, "svcid");
- r = CAppContentHistory::Delete(CAppContentHistory::TYPE_CHANNEL, svcid);
- if (r < 0) {
- _ERR("failed to delete history");
- bundle_free(args);
- return -1;
- }
- bundle_free(args);
- } else {
- r = CAppContentHistory::Delete(CAppContentHistory::TYPE_APPS, it->actor);
- if (r < 0) {
- _ERR("failed to delete history");
- return -1;
- }
- }
- break;
- default:
- break;
- }
-
- return 0;
-}
-
-int engine_dbar_item_del_all(enum engine_dbar_content_type type)
-{
int r;
- if (type > ENGINE_DBAR_CONTENT_TYPE_MAX) {
- _ERR("Invalid argument");
- return -1;
- }
-
switch (type) {
- case ENGINE_DBAR_CONTENT_TYPE_HISTORY:
+ case CEngineDBarItemContent::TYPE_HISTORY:
r = CAppContentHistory::DeleteAll();
if (r < 0) {
_ERR("failed to delete all");
--- /dev/null
+/*
+ * Copyright (c) 2014 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 __ENGINE_H__
+#define __ENGINE_H__
+
+
+#include <Eina.h>
+#include <stdbool.h>
+#include "bus.h"
+#include <json-glib/json-glib.h>
+#include <app-content-favorite.h>
+#include "engine/include/Entity.h"
+
+class CEngine;
+
+#include "engine/include/EngineBarItem.h"
+#include "engine/include/EngineDBarItemContent.h"
+#include "engine/include/EngineDBarItem.h"
+#include "engine/include/EngineUBarItem.h"
+
+
+#define PACKAGE_LIVE_TV "org.tizen.live-tv-ref"
+
+#define GUM_ATTR_NAME "username"
+#define GUM_ATTR_USERTYPE "usertype"
+#define GUM_ATTR_UID "uid"
+#define GUM_ATTR_ICON "icon"
+
+
+class CEngine {
+private:
+ struct SEngine *m;
+
+private:
+ static void sm_CbBusReady(CBaseBus *bus, void *data);
+ static void sm_CbBusEnd(CBaseBus *bus, void *data);
+
+ static bool sm_CbAddLabel(CBus::SLabel *lbl, void *data);
+ static bool sm_CbAddAlbum(CBus::SAlbum *album, CBus::SAction *act, void *data);
+ static bool sm_CbAddContent(CBus::SContent *content, CBus::SAction *act, void *data);
+ static bool sm_CbAddPin(CBus::SPin *pin, CBus::SAction *act, void *data);
+ static bool sm_CbDelContent(const char *svcid, int ctnt_id, void *data);
+ static bool sm_CbDelAll(const char *svcid, bool reload, void *data);
+
+ bool m_OnAddLabel(CBus::SLabel *lbl);
+ bool m_OnAddAlbum(CBus::SAlbum *album, CBus::SAction *act);
+ bool m_OnAddContent(CBus::SContent *content, CBus::SAction *act);
+ bool m_OnAddPin(CBus::SPin *pin, CBus::SAction *act);
+ bool m_OnDelContent(const char *svcid, int ctnt_id);
+ bool m_OnDelAll(const char *svcid, bool reload);
+
+
+ int _load_login_user(uid_t uid);
+ int _del_pin_item(Eina_Bool free);
+ void _update_pin_list(void);
+ void _unload_config_user(void);
+ void _unload_bar_items(void);
+ void _unload_ubar_items(void);
+ bool _load_bar_items(JsonReader *reader);
+
+ bool m_LoadUser(void);
+ bool m_LoadItemConfig(void);
+ void m_UnloadConfig(void);
+
+
+public:
+ CEngine() : m(0) {}
+ virtual ~CEngine() {}
+ bool FlagCreate(void) { return !!m; }
+
+ bool Create(void);
+ virtual void Destroy(void);
+
+ bool GetUserInfo(const char **name, const char **thumb_bg, const char **thumb);
+
+ const Eina_List *BarItemsList(void);
+ const Eina_List *UBarItemsList(void);
+
+ bool DelPin(CEngineBarItem *it);
+
+ void AddUBar(CEngineUBarItem *it);
+ bool Delete(CEngineUBarItem *it, const char *password);
+
+ void SetUpdateCallback(void(*update_cb)(void *data, bool focus), void *data);
+ void InvokeUpdateCallback(void);
+
+ bool GetPrivilege(void);
+
+ bool Swap(CEngineBarItem *it1, CEngineBarItem *it2);
+};
+
+
+/* bar */
+int engine_bar_item_get_pin_count(void);
+
+/* ubar */
+int engine_dbar_item_del_all(CEngineDBarItemContent::EType type);
+
+
+#endif /* __ErGINE_H__ */
--- /dev/null
+#ifndef __ENGINE_BAR_ITEM_H__
+#define __ENGINE_BAR_ITEM_H__
+
+
+#include "Entity.h"
+
+
+class CEngineDBarItem;
+
+
+class CEngineBarItem : public CEntity {
+public:
+ enum EVInt {
+ VINT_COLUMN,
+ EINT_MAX,
+ };
+ enum EVStr {
+ VSTR_ICON,
+ VSTR_ICON_FOCUS,
+ VSTR_NAME,
+ VSTR_BUS_NAME,
+ VSTR_OBJECT_PATH,
+ VSTR_APP,
+ VSTR_ARGS,
+ VSTR_PIN_ID,
+ VSTR_IN,
+ VSTR_NOCTNT_TITLE,
+ VSTR_NOCTNT_DESC,
+ VSTR_SVC_ID,
+ VSTR_MAX,
+ };
+private:
+ struct SEngineBarItem *m;
+
+public:
+ CEngineBarItem();
+ virtual ~CEngineBarItem();
+
+ void SetEngine(CEngine *eng);
+
+ void SetCtntId(int id);
+ int CtntId(void);
+
+ void SetType(CAppContentFavorite::EType type);
+ CAppContentFavorite::EType Type(void);
+
+ void SetColor(int r, int g, int b);
+ bool GetColor(int *r, int *g, int *b);
+
+ void SetContentColumn(int column);
+ bool GetContentColumn(int *content_column);
+
+ bool Launch(void);
+ void SetIsPinned(Eina_Bool pinned);
+ Eina_Bool IsPinned(void);
+
+ void SetUpdateCallback(void(*update_cb)(CEngineBarItem *item, void *data), void *data);
+ void InvokeUpdateCallback(void);
+
+ const Eina_List *DBarItems(void);
+
+ void AddItem(CEngineDBarItem *item);
+ void RemoveAllDBar(void);
+
+ bool RemoveDBar(int ctnt_id);
+
+
+ static CEngineBarItem *Alloc(JsonReader *reader, int idx);
+ static CEngineBarItem *Alloc(const char *title, CBus::EPinType type,
+ const char *icon, const char *svcid,
+ CBus::EActionOp action, const char *actor,
+ const char *args, const char *pinid);
+};
+
+
+#endif /* __ENGINE_BAR_ITEM_H__ */
--- /dev/null
+#ifndef __ENGINE_DBAR_ITEM_H__
+#define __ENGINE_DBAR_ITEM_H__
+
+
+#include "Entity.h"
+#include "EngineDBarItemContent.h"
+
+
+class CEngineDBarItem : public CEntity {
+private:
+ struct SEngineDBarItem *m;
+
+public:
+ enum EVInt {
+ VINT_CONTENT_ID,
+ VINT_STYLE,
+ VINT_ACTION,
+ VINT_MAX,
+ };
+ enum EVStr {
+ VSTR_ACTOR,
+ VSTR_NAME,
+ VSTR_ARGS,
+ VSTR_MAX,
+ };
+
+
+ enum EStyle {
+ STYLE_CONTENT,
+ STYLE_LABEL,
+ STYLE_ALBUM,
+ STYLE_MAX
+ };
+
+private:
+ bool m_LaunchApp(void);
+
+public:
+ CEngineDBarItem(CEngineBarItem *parent);
+ virtual ~CEngineDBarItem();
+
+ void AddContent(CEngineDBarItemContent *ctnt);
+ const Eina_List *ContentsList(void);
+
+ const char *In(void);
+ bool GetColor(int *r, int *g, int *b);
+ bool Launch(void);
+ bool Del(CEngineDBarItemContent::EType type);
+};
+
+
+#endif /* __ENGINE_DBAR_ITEM_H__ */
\ No newline at end of file
--- /dev/null
+#ifndef __ENGINE_DBAR_ITEM_CONTENT_H__
+#define __ENGINE_DBAR_ITEM_CONTENT_H__
+
+
+#include "../../bus.h"
+#include "Entity.h"
+
+
+class CEngineDBarItemContent : public CEntity {
+public:
+ enum EVInt {
+ VINT_MAX,
+ };
+ enum EVStr {
+ VSTR_SUBTITLE,
+ VSTR_DESCRIPTION,
+ VSTR_DETAIL,
+ VSTR_THUMBNAIL,
+ VSTR_ICON,
+ VSTR_MAX,
+ };
+
+ enum EType {
+ TYPE_IMAGE,
+ TYPE_VIDEO,
+ TYPE_MUSIC,
+ TYPE_BROADCAST,
+ TYPE_APP,
+ TYPE_SOURCE,
+ TYPE_NOTIFICATION_NOTI,
+ TYPE_NOTIFICATION_ONGOING,
+ TYPE_HISTORY,
+ TYPE_MAX
+ };
+
+private:
+ struct SEngineDBarItemContent *m;
+
+public:
+ CEngineDBarItemContent(EType type);
+ virtual ~CEngineDBarItemContent();
+
+ EType Type(void);
+
+ static CEngineDBarItemContent *Alloc(CBus::SContent *bus_ctnt);
+};
+
+
+#endif /* __ENGINE_DBAR_ITEM_CONTENT_H__ */
\ No newline at end of file
--- /dev/null
+#ifndef __ENGINE_UBAR_ITEM_H__
+#define __ENGINE_UBAR_ITEM_H__
+
+
+#include "../include/Entity.h"
+
+
+class CEngineUBarItem : public CEntity {
+public:
+ enum EVInt {
+ VINT_AGE,
+ VINT_MAX,
+ };
+ enum EVStr {
+ VSTR_NAME,
+ VSTR_THUMB,
+ VSTR_THUMB_BG,
+ VSTR_MAX,
+ };
+private:
+ struct SEngineUBarItem *m;
+
+public:
+ CEngineUBarItem(CEngine *eng);
+ virtual ~CEngineUBarItem();
+
+ bool IsPassword(const char *password);
+ bool ChangeUser(const char *password);
+ bool Update(const char *icon, const char *password);
+
+ static CEngineUBarItem *Alloc(CEngine *engine, const char *name, const char *icon);
+};
+
+
+bool engine_ubar_item_add(CEngine *eng, const char *name, const char *password, const char *icon);
+
+
+#endif /* __ENGINE_UBAR_ITEM_H__ */
\ No newline at end of file
--- /dev/null
+#ifndef __ENTITY_H__
+#define __ENTITY_H__
+
+
+class CEntity {
+private:
+ struct SEntity *m;
+
+public:
+ CEntity(int nIntMax, int nStrMax);
+ virtual ~CEntity();
+
+ void SetInt(int idx, int value);
+ int Int(int idx);
+
+ void SetStr(int idx, const char *str);
+ const char *Str(int idx);
+};
+
+
+#endif /* __ENTITY_H__ */
--- /dev/null
+#include <string.h>
+#include <Eina.h>
+#include <aul.h>
+#include <glib.h>
+
+#include <app-content-history.h>
+
+#include "../../engine.h"
+#include "../../common.h"
+#include "../include/EngineBarItem.h"
+
+
+struct SEngineBarItem {
+ CEngine *eng;
+
+ int r;
+ int g;
+ int b;
+ int content_column;
+ Eina_List *dbar_its;
+ int ctnt_id;
+ CAppContentFavorite::EType type;
+ Eina_Bool is_pinned;
+
+ void(*update_cb)(CEngineBarItem *it, void *data);
+ void *update_cb_data;
+};
+
+
+CEngineBarItem::CEngineBarItem() : CEntity(EINT_MAX, VSTR_MAX)
+{
+ m = new SEngineBarItem;
+ memset(m, 0, sizeof(SEngineBarItem));
+}
+
+
+CEngineBarItem::~CEngineBarItem()
+{
+ delete m;
+ m = NULL;
+}
+
+
+void CEngineBarItem::SetEngine(CEngine *eng)
+{
+ ASSERT(m);
+
+ m->eng = eng;
+}
+
+
+void CEngineBarItem::SetCtntId(int id)
+{
+ ASSERT(m);
+
+ m->ctnt_id = id;
+}
+
+
+int CEngineBarItem::CtntId(void)
+{
+ ASSERT(m);
+
+ return m->ctnt_id;
+}
+
+
+void CEngineBarItem::SetType(CAppContentFavorite::EType type)
+{
+ ASSERT(m);
+
+ m->type = type;
+}
+
+
+CAppContentFavorite::EType CEngineBarItem::Type(void)
+{
+ ASSERT(m);
+
+ return m->type;
+}
+
+
+void CEngineBarItem::SetColor(int r, int g, int b)
+{
+ ASSERT(m);
+
+ m->r = r;
+ m->g = g;
+ m->b = b;
+}
+
+
+bool CEngineBarItem::GetColor(int *r, int *g, int *b)
+{
+ ASSERT(m);
+
+ if (r)
+ *r = m->r;
+ if (g)
+ *g = m->g;
+ if (b)
+ *b = m->b;
+
+ return true;
+}
+
+
+bool CEngineBarItem::Launch(void)
+{
+ ASSERT(m);
+
+ int r;
+ bundle *args;
+
+ if (!Str(VSTR_APP)) {
+ _ERR("Application name is not found");
+ return false;
+ }
+
+ if (Str(VSTR_ARGS))
+ args = bundle_decode((const bundle_raw*)Str(VSTR_ARGS), strlen(Str(VSTR_ARGS)));
+ else
+ args = NULL;
+
+ r = aul_launch_app(Str(VSTR_APP), args);
+ if (args)
+ bundle_free(args);
+ if (r < 0) {
+ _ERR("Open app failed");
+ if (args)
+ bundle_free(args);
+ return false;
+ }
+
+ if (!strcmp(Str(VSTR_APP), PACKAGE_LIVE_TV))
+ return true;
+
+ r = CAppContentHistory::Add(CAppContentHistory::TYPE_APPS, Str(VSTR_APP));
+ if (r < 0) {
+ _ERR("failed to add history");
+ return false;
+ }
+
+ return true;
+}
+
+
+void CEngineBarItem::SetIsPinned(Eina_Bool pinned)
+{
+ ASSERT(m);
+
+ m->is_pinned = pinned;
+}
+
+Eina_Bool CEngineBarItem::IsPinned(void)
+{
+ ASSERT(m);
+
+ return m->is_pinned;
+}
+
+
+void CEngineBarItem::SetUpdateCallback(void(*update_cb)(CEngineBarItem *it, void *data),
+ void *data)
+{
+ ASSERT(m);
+
+ m->update_cb = update_cb;
+ m->update_cb_data = data;
+}
+
+
+void CEngineBarItem::InvokeUpdateCallback(void)
+{
+ ASSERT(m);
+
+ if (m->update_cb)
+ m->update_cb(this, m->update_cb_data);
+}
+
+
+
+const Eina_List *CEngineBarItem::DBarItems(void)
+{
+ ASSERT(m);
+
+ return m->dbar_its;
+}
+
+
+void CEngineBarItem::AddItem(CEngineDBarItem *item)
+{
+ ASSERT(m);
+
+ m->dbar_its = eina_list_append(m->dbar_its, item);
+}
+
+
+void CEngineBarItem::RemoveAllDBar(void)
+{
+ ASSERT(m);
+
+ CEngineDBarItem *dit;
+ void *obj;
+
+ EINA_LIST_FREE(m->dbar_its, obj) {
+ dit = (CEngineDBarItem *)obj;
+ delete dit;
+ }
+ m->dbar_its = NULL;
+}
+
+
+bool CEngineBarItem::RemoveDBar(int ctnt_id)
+{
+ CEngineDBarItem *dit;
+ Eina_List *l;
+ void *obj;
+
+ EINA_LIST_FOREACH(m->dbar_its, l, obj) {
+ dit = (CEngineDBarItem*)obj;
+ if (dit->Int(CEngineDBarItem::VINT_CONTENT_ID) == ctnt_id) {
+ m->dbar_its = eina_list_remove_list(m->dbar_its, l);
+ delete dit;
+ InvokeUpdateCallback();
+ return true;
+ }
+ }
+
+ return false;
+}
--- /dev/null
+#include <string.h>
+#include <Eina.h>
+#include <aul.h>
+#include <glib.h>
+
+#include <app-content-history.h>
+#include <app-content-favorite.h>
+
+#include "../../bus.h"
+#include "../../common.h"
+#include "../../engine.h"
+#include "../include/EngineBarItem.h"
+#include "../include/EngineDBarItem.h"
+
+
+struct SEngineDBarItem {
+ CEngineBarItem *parent;
+
+ int ctnt_id;
+ CEngineDBarItem::EStyle style;
+ CBus::EActionOp action;
+
+ Eina_List *ctnts;
+};
+
+
+CEngineDBarItem::CEngineDBarItem(CEngineBarItem *parent) : CEntity(VINT_MAX, VSTR_MAX)
+{
+ m = new SEngineDBarItem;
+ memset(m, 0, sizeof(*m));
+ m->parent = parent;
+}
+
+
+CEngineDBarItem::~CEngineDBarItem()
+{
+ CEngineDBarItemContent *ctnt;
+ void *obj;
+
+ EINA_LIST_FREE(m->ctnts, obj) {
+ ctnt = (CEngineDBarItemContent *)obj;
+ delete ctnt;
+ }
+
+ delete m;
+ m = NULL;
+}
+
+
+void CEngineDBarItem::AddContent(CEngineDBarItemContent *ctnt)
+{
+ ASSERT(m);
+
+ m->ctnts = eina_list_append(m->ctnts, ctnt);
+}
+
+
+
+const Eina_List *CEngineDBarItem::ContentsList(void)
+{
+ ASSERT(m);
+
+ return m->ctnts;
+}
+
+
+
+const char *CEngineDBarItem::In(void)
+{
+ ASSERT(m);
+
+ return m->parent->Str(CEngineBarItem::VSTR_IN);// In();
+}
+
+
+bool CEngineDBarItem::GetColor(int *r, int *g, int *b)
+{
+ ASSERT(m);
+ return m->parent->GetColor(r, g, b);
+}
+
+
+bool CEngineDBarItem::Launch(void)
+{
+ ASSERT(m);
+
+ switch (m->action) {
+ case CBus::ACTION_OP_LAUNCH_NONE:
+ _ERR("Non-launchable item");
+ break;
+
+ case CBus::ACTION_OP_LAUNCH_APP:
+ return m_LaunchApp();
+
+ case CBus::ACTION_OP_LAUNCH_SERVICE:
+ _ERR("Service launching is not supported yet");
+ break;
+
+ default:
+ _ERR("Invalid action type");
+ break;
+ }
+
+ return true;
+}
+
+
+bool CEngineDBarItem::Del(CEngineDBarItemContent::EType type)
+{
+ ASSERT(0 <= type && type <= CEngineDBarItemContent::TYPE_MAX);
+ bundle *args;
+ const char *svcid;
+ int r;
+
+ if (!Str(VSTR_ACTOR)) {
+ _ERR("Invalid argument");
+ return false;
+ }
+
+ switch (type) {
+ case CEngineDBarItemContent::TYPE_HISTORY:
+ if (!strcmp(Str(VSTR_ACTOR), PACKAGE_LIVE_TV)) {
+ if (!Str(VSTR_ARGS))
+ return false;
+
+ args = bundle_decode((const bundle_raw*)Str(VSTR_ARGS),
+ strlen(Str(VSTR_ARGS)));
+ if (!args) {
+ _ERR("failed to decode bundle");
+ return false;
+ }
+
+ svcid = bundle_get_val(args, "svcid");
+ r = CAppContentHistory::Delete(CAppContentHistory::TYPE_CHANNEL, svcid);
+ if (r < 0) {
+ _ERR("failed to delete history");
+ bundle_free(args);
+ return false;
+ }
+ bundle_free(args);
+ }
+ else {
+ r = CAppContentHistory::Delete(CAppContentHistory::TYPE_APPS, Str(VSTR_ACTOR));
+ if (r < 0) {
+ _ERR("failed to delete history");
+ return false;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return true;
+}
+
+
+
+bool CEngineDBarItem::m_LaunchApp(void)
+{
+ int r;
+ bundle *args;
+ CEngineDBarItemContent *ctnt;
+
+ if (Str(CEngineDBarItem::VSTR_ARGS))
+ args = bundle_decode((const bundle_raw*)Str(CEngineDBarItem::VSTR_ARGS),
+ strlen(Str(CEngineDBarItem::VSTR_ARGS)));
+ else
+ args = NULL;
+
+ r = aul_launch_app(Str(CEngineDBarItem::VSTR_ACTOR), args);
+ if (args)
+ bundle_free(args);
+ if (r < 0) {
+ _ERR("launch app failed");
+ return false;
+ }
+
+ ctnt = (CEngineDBarItemContent *)
+ eina_list_data_get(ContentsList());
+ if (!ctnt) {
+ _ERR("get ctnt failed");
+ return true;
+ }
+
+ if ((ctnt->Type() == CEngineDBarItemContent::TYPE_BROADCAST) ||
+ !strcmp(Str(CEngineDBarItem::VSTR_ACTOR), PACKAGE_LIVE_TV))
+ return true;
+
+ r = CAppContentHistory::Add(CAppContentHistory::TYPE_APPS, Str(CEngineDBarItem::VSTR_ACTOR));
+ if (r < 0) {
+ _ERR("failed to add history");
+ return true;
+ }
+
+ return true;
+}
+
--- /dev/null
+#include <string.h>\r
+#include "../../common.h"\r
+#include "../include/EngineDBarItemContent.h"\r
+\r
+
+struct SEngineDBarItemContent {
+ CEngineDBarItemContent::EType type;
+};
+
+
+CEngineDBarItemContent::CEngineDBarItemContent(EType type) : CEntity(VINT_MAX, VSTR_MAX)
+{
+ m = new SEngineDBarItemContent;
+ memset(m, 0, sizeof(*m));
+ m->type = type;
+}
+
+
+CEngineDBarItemContent::~CEngineDBarItemContent()
+{
+ delete m;
+ m = NULL;
+}
+
+
+CEngineDBarItemContent::EType CEngineDBarItemContent::Type(void)
+{
+ ASSERT(m);
+
+ return m->type;
+}
+
+
+CEngineDBarItemContent* CEngineDBarItemContent::Alloc(CBus::SContent *bus_ctnt)
+{
+ ASSERT(bus_ctnt);
+
+ EType type;
+
+ switch (bus_ctnt->type) {
+ case CBus::CONTENT_TYPE_IMAGE:
+ type = TYPE_IMAGE;
+ break;
+ case CBus::CONTENT_TPPE_VIDEO:
+ type = TYPE_VIDEO;
+ break;
+ case CBus::CONTENT_TYPE_MUSIC:
+ type = TYPE_MUSIC;
+ break;
+ case CBus::CONTENT_TYPE_BROADCAST:
+ type = TYPE_BROADCAST;
+ break;
+ case CBus::CONTENT_TYPE_APP:
+ type = TYPE_APP;
+ break;
+ case CBus::CONTENT_TYPE_SOURCE:
+ type = TYPE_SOURCE;
+ break;
+ case CBus::CONTENT_TYPE_NOTIFICATION_NOTI:
+ type = TYPE_NOTIFICATION_NOTI;
+ break;
+ case CBus::CONTENT_TYPE_NOTIFICATION_ONGOING:
+ type = TYPE_NOTIFICATION_ONGOING;
+ break;
+ case CBus::CONTENT_TYPE_HISTORY:
+ type = TYPE_HISTORY;
+ break;
+ default:
+ _ERR("Invalid content type");
+ return NULL;
+ }
+
+ CEngineDBarItemContent *ctnt;
+ ctnt = new CEngineDBarItemContent(type);
+ if (!ctnt) {
+ _ERR("calloc failed");
+ return NULL;
+ }
+
+ ctnt->SetStr(VSTR_SUBTITLE, bus_ctnt->subtitle);
+ ctnt->SetStr(VSTR_DESCRIPTION, bus_ctnt->description);
+ ctnt->SetStr(VSTR_DETAIL, bus_ctnt->detail);
+ ctnt->SetStr(VSTR_THUMBNAIL, bus_ctnt->thumbnail);
+ ctnt->SetStr(VSTR_ICON, bus_ctnt->icon);
+
+ return ctnt;
+}
--- /dev/null
+#include <Elementary.h>
+#include <gum/gum-user.h>
+#include <gum/gum-user-service.h>
+#include <gum/common/gum-user-types.h>
+#include "../../common.h"
+#include "../../engine.h"
+#include "../include/EngineUBarItem.h"
+
+
+#define GUM_ATTR_PASSWORD "secret"
+
+
+struct SEngineUBarItem {
+ CEngine *eng;
+};
+
+
+CEngineUBarItem::CEngineUBarItem(CEngine *eng) : CEntity(VINT_MAX, VSTR_MAX)
+{
+ m = new SEngineUBarItem;
+ memset(m, 0, sizeof(CEngineUBarItem));
+ m->eng = eng;
+}
+
+
+CEngineUBarItem::~CEngineUBarItem()
+{
+ delete m;
+ m = NULL;
+}
+
+
+bool CEngineUBarItem::IsPassword(const char *password)
+{
+ ASSERT(m);
+ ASSERT(password);
+
+ GumUser *user;
+ const char *_password;
+ bool r;
+
+ r = false;
+ user = gum_user_get_by_name_sync(Str(VSTR_NAME), FALSE);
+ if (!user) {
+ _ERR("failed to get user");
+ return false;
+ }
+
+ g_object_get(G_OBJECT(user), GUM_ATTR_PASSWORD, &_password, NULL);
+
+ if (!strcmp(password, _password))
+ r = true;
+
+ g_object_unref(user);
+
+ return r;
+}
+
+
+bool CEngineUBarItem::ChangeUser(const char *password)
+{
+ ASSERT(m);
+ ASSERT(password);
+
+ int r;
+ r = bus_change_user(Str(VSTR_NAME), password);
+ if (r < 0) {
+ _ERR("failed to switch user");
+ return false;
+ }
+
+ elm_exit();
+
+ return true;
+}
+
+
+bool CEngineUBarItem::Update(const char *icon, const char *password)
+{
+ ASSERT(m);
+ ASSERT(icon);
+ ASSERT(password);
+
+ GumUser *user;
+ gboolean r;
+
+ user = gum_user_get_by_name_sync(Str(VSTR_NAME), FALSE);
+ if (!user) {
+ _ERR("failed to get user");
+ return false;
+ }
+
+ g_object_set(G_OBJECT(user), GUM_ATTR_PASSWORD, password,
+ GUM_ATTR_ICON, icon, NULL);
+
+ r = gum_user_update_sync(user);
+ if (!r) {
+ _ERR("failed to update user");
+ g_object_unref(user);
+ return false;
+ }
+
+ SetStr(VSTR_THUMB, icon);
+
+ g_object_unref(user);
+
+ return true;
+}
+
+
+
+bool engine_ubar_item_add(CEngine *eng, const char *name,
+ const char *password, const char *icon)
+{
+ CEngineUBarItem *item;
+ GumUser *user;
+ gboolean r;
+
+ if (!eng || !name || !password || !icon) {
+ _ERR("Invalid argument");
+ return false;
+ }
+
+ user = gum_user_create_sync(FALSE);
+ if (!user) {
+ _ERR("failed to get user");
+ return false;
+ }
+
+ g_object_set(G_OBJECT(user), GUM_ATTR_NAME, name,
+ GUM_ATTR_PASSWORD, password,
+ GUM_ATTR_USERTYPE, GUM_USERTYPE_NORMAL,
+ GUM_ATTR_ICON, icon, NULL);
+
+ r = gum_user_add_sync(user);
+ if (!r) {
+ _ERR("failed to add user");
+ g_object_unref(user);
+ return false;
+ }
+
+ item = CEngineUBarItem::Alloc(eng, name, icon);
+ eng->AddUBar(item);
+
+
+ g_object_unref(user);
+
+ return true;
+}
--- /dev/null
+#include <string.h>
+#include "dbg.h"
+#include "../../common.h"
+#include "../include/Entity.h"
+
+
+struct SEntity {
+ int* nInteger;
+ int nIntegerCount;
+
+ char **szString;
+ int nStringCount;
+};
+
+
+CEntity::CEntity(int nIdxMax, int nStrMax)
+{
+ m = new SEntity;
+ m->nIntegerCount = nIdxMax;
+ m->nInteger = new int[m->nIntegerCount];
+ memset(m->nInteger, 0, sizeof(int)* m->nIntegerCount);
+
+ m->nStringCount = nStrMax;
+ m->szString = new char*[m->nStringCount];
+ memset(m->szString, 0, sizeof(char*)* m->nStringCount);
+}
+
+CEntity::~CEntity()
+{
+ int a;
+ for (a = m->nStringCount - 1; a >= 0; a--) {
+ delete[] m->szString;
+ }
+ delete m;
+ m = NULL;
+}
+
+
+void CEntity::SetInt(int idx, int value)
+{
+ ASSERT(m);
+ ASSERT(0 <= idx && idx < m->nIntegerCount);
+
+ m->nInteger[idx] = value;
+}
+
+
+int CEntity::Int(int idx)
+{
+ ASSERT(m);
+ ASSERT(0 <= idx && idx < m->nIntegerCount);
+
+ return m->nInteger[idx];
+}
+
+
+void CEntity::SetStr(int idx, const char *str)
+{
+ ASSERT(m);
+ ASSERT(0 <= idx && idx < m->nStringCount);
+
+ delete[] m->szString[idx];
+ m->szString[idx] = NULL;
+ if (str) {
+ m->szString[idx] = new char[strlen(str) + 1];
+ if (m->szString[idx])
+ strcpy(m->szString[idx], str);
+ }
+}
+
+
+const char *CEntity::Str(int idx)
+{
+ ASSERT(m);
+ ASSERT(0 <= idx && idx < m->nStringCount);
+
+ return m->szString[idx];
+}
struct _hbar_item {
Evas_Object *eo;
- struct engine_bar_item *it;
+ CEngineBarItem *it;
struct _hbar_data *bar;
Eina_Bool dirty;
struct bar_info *dbar;
return;
item = (struct _hbar_item *)data;
- engine_bar_item_launch(item->it);
+ item->it->Launch();
}
-static int _launch_app(struct bar_info *info)
+static bool _launch_app(struct bar_info *info)
{
struct _hbar_data *bar;
struct _hbar_item *item;
if (!info)
- return EINA_FALSE;
+ return false;
bar = (struct _hbar_data *)info->data;
item = bar->cur;
if (!item) {
_ERR("Invalid argument");
- return -1;
+ return false;
}
- return engine_bar_item_launch(item->it);
+ return item->it->Launch();
}
static Eina_Bool _move(struct bar_info *info)
{
struct _hbar_data *bar;
struct _hbar_item *item;
- Eina_Bool r;
+ bool r;
if (!info || !info->data)
return BAR_EVENT_ERROR;
}
static inline Evas_Object *_add_hbar_item_bg(Evas_Object *base,
- struct engine_bar_item *it)
+ CEngineBarItem *it)
{
Evas_Object *bg;
int r, g, b;
g = 128;
b = 128;
- engine_bar_item_get_color(it, &r, &g, &b);
+ it->GetColor(&r, &g, &b);
evas_object_color_set(bg, r, g, b, 255);
return bg;
}
static Evas_Object *_new_hbar_item(Evas_Object *p,
- struct _hbar_item *item, struct engine_bar_item *it)
+ struct _hbar_item *item, CEngineBarItem *it)
{
Evas_Object *ly, *eo, *lbl;
goto err;
elm_object_part_content_set(ly, PART_BG2, eo);
- eo = _add_icon(ly, engine_bar_item_get_icon(it));
+ eo = _add_icon(ly, it->Str(CEngineBarItem::VSTR_ICON));
if (!eo)
goto err;
elm_object_part_content_set(ly, PART_ICON, eo);
- eo = _add_icon(ly, engine_bar_item_get_icon_focus(it));
+ eo = _add_icon(ly, it->Str(CEngineBarItem::VSTR_ICON_FOCUS));
if (!eo)
goto err;
elm_object_part_content_set(ly, PART_ICON_FOCUS, eo);
- lbl = _add_label(ly, engine_bar_item_get_name(it));
+ lbl = _add_label(ly, it->Str(CEngineBarItem::VSTR_NAME));
if (!lbl)
goto err;
elm_object_part_content_set(ly, PART_NAME, lbl);
}
static struct _hbar_item *_pack_item(struct _hbar_data *bar,
- struct engine_bar_item *it)
+ CEngineBarItem *it)
{
Evas_Object *base;
struct _hbar_item *item;
elm_object_signal_emit(dbar, SIG_SHOW, SRC_PROG);
}
-static void _updated(struct engine_bar_item *it, void *data)
+static void _updated(CEngineBarItem *it, void *data)
{
struct _hbar_item *item;
struct _hbar_data *bar;
const Eina_List *list;
Eina_List *l;
- struct engine_bar_item *it;
+ CEngineBarItem *it;
struct _hbar_item *item;
int cnt, r;
void *obj;
EINA_LIST_FREE(bar->list, obj) {
item = (struct _hbar_item *)obj;
- engine_bar_item_set_update_cb(item->it, NULL, NULL);
+ item->it->SetUpdateCallback(NULL, NULL);
evas_object_del(item->eo);
if (item->dbar)
item->dbar->ops->release(item->dbar);
bar->list = NULL;
cnt = 0;
- list = engine_get_bar_items((struct engine *)eng);
+ list = ((CEngine*)eng)->BarItemsList();
if (!list)
return cnt;
EINA_LIST_FOREACH((Eina_List *)list, l, obj) {
- it = (struct engine_bar_item *)obj;
- r = strcmp(engine_bar_item_get_in(it), "homebar");
+ it = (CEngineBarItem *)obj;
+ r = strcmp(it->Str(CEngineBarItem::VSTR_IN), "homebar");
if (r != 0)
continue;
item = _pack_item(bar, it);
continue;
bar->list = eina_list_append(bar->list, item);
- engine_bar_item_set_update_cb(item->it, _updated, item);
+ item->it->SetUpdateCallback(_updated, item);
cnt++;
}
if (bar) {
EINA_LIST_FREE(bar->list, obj) {
item = (struct _hbar_item *)obj;
- engine_bar_item_set_update_cb(item->it, NULL, NULL);
+ item->it->SetUpdateCallback(NULL, NULL);
evas_object_del(item->eo);
if (item->dbar)
item->dbar->ops->release(item->dbar);
Evas_Object *base;
Evas_Object *win;
- struct engine *eng;
+ CEngine *eng;
enum _hscr_state state;
Eina_Bool focus_lock;
elm_win_lower(hscr->win);
}
-struct homescreen *homescreen_init(struct engine *eng)
+struct homescreen *homescreen_init(CEngine *eng)
{
struct homescreen *hscr;
struct homescreen;
-struct homescreen *homescreen_init(struct engine *eng);
+struct homescreen *homescreen_init(CEngine *eng);
int homescreen_load(struct homescreen *hscr, Evas_Object *win);
void homescreen_fini(struct homescreen *hscr);
void homescreen_show(struct homescreen *hscr);
Evas_Object *win;
struct homescreen *hscr;
- struct engine *eng;
+ CEngine *eng;
int initted;
};
{
struct _appdata *ad;
struct homescreen *hscr;
- struct engine *eng;
+ CEngine *eng;
Evas_Object *win;
int r;
elm_theme_overlay_add(NULL, THEMEFILE);
elm_config_focus_move_policy_set(ELM_FOCUS_MOVE_POLICY_CLICK);
- eng = engine_init();
+ eng = new CEngine;
if (!eng) {
_ERR("failed to initialize engine");
return false;
}
+ eng->Create();
hscr = homescreen_init(eng);
if (!hscr) {
_ERR("failed to initialize homescreen");
- engine_fini(eng);
+ eng->Destroy();
+ delete eng;
return false;
}
if (!win) {
_ERR("failed to create window");
homescreen_fini(hscr);
- engine_fini(eng);
+ eng->Destroy();
+ delete eng;
return false;
}
if (r != 0) {
_ERR("failed to load homescreen");
homescreen_fini(hscr);
- engine_fini(eng);
+
+ eng->Destroy();
+ delete eng;
evas_object_del(win);
return false;
}
ad = (struct _appdata *)user_data;
homescreen_fini(ad->hscr);
- engine_fini(ad->eng);
+ ad->eng->Destroy();
+ delete ad->eng;
if (ad->win)
evas_object_del(ad->win);
Evas_Object *bx;
Eina_List *list;
Evas_Object *base;
- struct engine *eng;
+ CEngine *eng;
struct _ubar_item *cur;
struct _ubar_item *popup_cur;
struct bar_cb focus_cb;
Evas_Object *pw_entry;
Evas_Object *left_arrow;
Evas_Object *right_arrow;
- struct engine_ubar_item *it;
+ CEngineUBarItem *it;
struct _ubar_data *bar;
enum _popup_state state;
bool is_user;
return 0;
}
-static int _update_user(struct _ubar_data *bar, struct engine *eng)
+static int _update_user(struct _ubar_data *bar, CEngine *eng)
{
struct _ubar_item *item;
const char *thumb_bg;
thumb_bg = NULL;
thumb = NULL;
- engine_get_user_info(eng, &name, &thumb_bg, &thumb);
+ eng->GetUserInfo(&name, &thumb_bg, &thumb);
elm_image_file_set(item->ic_bg,
thumb_bg ? thumb_bg : DEF_USER_THUMB_BG, NULL);
elm_image_file_set(item->ic,
}
static struct _ubar_item *_pack_item(struct _ubar_data *bar,
- struct engine_ubar_item *it)
+ CEngineUBarItem *it)
{
Evas_Object *ly, *ic_bg, *ic, *lbl;
struct _ubar_item *item;
return NULL;
}
- engine_ubar_item_get_info(it, &name, &thumb_bg, &thumb, NULL);
+ name = it->Str(CEngineUBarItem::VSTR_NAME);
+ thumb_bg = it->Str(CEngineUBarItem::VSTR_THUMB_BG);
+ thumb = it->Str(CEngineUBarItem::VSTR_THUMB);
ly = elm_layout_add(bar->bx);
if (!ly) {
{
const Eina_List *list;
Eina_List *l;
- struct engine_ubar_item *it;
+ CEngineUBarItem *it;
struct _ubar_item *item;
void *obj;
bar->list = NULL;
elm_box_clear(bar->bx);
- list = engine_get_ubar_items((struct engine *)eng);
+ list = ((CEngine*)eng)->UBarItemsList();
if (!list)
return -1;
EINA_LIST_FOREACH((Eina_List *)list, l, obj) {
- it = (struct engine_ubar_item *)obj;
+ it = (CEngineUBarItem *)obj;
item = _pack_item(bar, it);
if (!item)
continue;
{
struct _ubar_data *bar;
int r;
- struct engine *engine;
+ CEngine *engine;
if (!info || !info->data || !eng) {
_ERR("Invalid argument");
}
bar = (struct _ubar_data *)info->data;
- engine = (struct engine *)eng;
+ engine = (CEngine *)eng;
r = _update_user(bar, engine);
if (r < 0)
return EINA_FALSE;
}
- if (!engine_ubar_item_delete(bar->eng, item->it, password)) {
+ if (!bar->eng->Delete(item->it, password)) {
_ERR("failed to delete user");
_show_message(item, SIG_SHOW_SYSTEM_FAIL);
return EINA_FALSE;
}
elm_image_file_get(cur->ic, &icon, NULL);
- if (!engine_ubar_item_update(bar->eng, item->it, icon, password)) {
+ if (!item->it->Update(icon, password)) {
_ERR("failed to update user");
_show_message(item, SIG_SHOW_SYSTEM_FAIL);
return EINA_FALSE;
}
evas_object_show(popup);
- engine_ubar_item_get_info(item->it, &name, NULL, &thumb, NULL);
+ name = item->it->Str(CEngineUBarItem::VSTR_NAME);
+ thumb = item->it->Str(CEngineUBarItem::VSTR_THUMB);
lbl = elm_label_add(ly);
if (!lbl) {
elm_label_slide_speed_set(lbl, LABEL_SLIDE_SPEED);
elm_label_slide_mode_set(lbl, ELM_LABEL_SLIDE_MODE_AUTO);
- engine_ubar_item_get_info(item->it, &name, NULL, &thumb, NULL);
+ name = item->it->Str(CEngineUBarItem::VSTR_NAME);
+ thumb = item->it->Str(CEngineUBarItem::VSTR_THUMB);
+
if (bar->popup_list) {
EINA_LIST_FOREACH(bar->popup_list, l, obj) {
cur = (struct _ubar_item *)obj;
elm_object_content_set(p, ly);
evas_object_show(ly);
- engine_ubar_item_get_info(item->it, &name, NULL, NULL, NULL);
+ name = item->it->Str(CEngineUBarItem::VSTR_NAME);
snprintf(buf, sizeof(buf), "%s %s?", MESSAGE_DELETE_POPUP,
name ? name : "");
return EINA_FALSE;
}
- if (!engine_ubar_item_change_user(item->bar->eng, item->it, password)) {
+ if (!item->it->ChangeUser(password)) {
_ERR("failed to delete user");
_show_message(item, SIG_SHOW_SYSTEM_FAIL);
return EINA_FALSE;
return EINA_FALSE;
}
- engine_ubar_item_get_info(item->it, &name, NULL, &thumb, NULL);
+ name = item->it->Str(CEngineUBarItem::VSTR_NAME);
+ thumb = item->it->Str(CEngineUBarItem::VSTR_THUMB);
ly = elm_layout_add(p);
if (!ly) {
return EINA_FALSE;
}
- return engine_ubar_item_get_privilege(item->bar->eng);
+ return item->bar->eng->GetPrivilege();
}
static Eina_Bool _add_ctxpopup_btn(struct _ubar_item *item, Evas_Object *base)