summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoohye Shin <soohye.shin@samsung.com>2015-04-30 09:00:28 +0900
committerSoohye Shin <soohye.shin@samsung.com>2015-05-07 19:58:27 +0900
commit70f3dca3f7b0508dd5319a1c486b7654527d487b (patch)
tree2c0b2cd0acdbf15e412c7c7325981a61395efbf1
parentcd65be552c0fc961fe5ddd6545ac8184acd47aba (diff)
downloadhomescreen-70f3dca3f7b0508dd5319a1c486b7654527d487b.tar.gz
homescreen-70f3dca3f7b0508dd5319a1c486b7654527d487b.tar.bz2
homescreen-70f3dca3f7b0508dd5319a1c486b7654527d487b.zip
remove MACRO
Change-Id: If449a58fe17844708758dd76daa1c467462f8f4d Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
-rw-r--r--src/BaseBus.cpp94
-rw-r--r--src/engine.cpp193
-rw-r--r--src/engine.h1
3 files changed, 201 insertions, 87 deletions
diff --git a/src/BaseBus.cpp b/src/BaseBus.cpp
index d2a7550..45bdb65 100644
--- a/src/BaseBus.cpp
+++ b/src/BaseBus.cpp
@@ -165,21 +165,34 @@ bool CBaseBus::m_Create(void)
{
GError *err = NULL;
- _CREATE_BEGIN{
- _CHECK(m->node = g_dbus_node_info_new_for_xml(BUS_INTROSPECTION_XML, &err))
- _CHECK(m->node->interfaces)
- _CHECK(m->owner_id = g_bus_own_name(m->info.bus_type, m->info.name,
+ m->node = g_dbus_node_info_new_for_xml(BUS_INTROSPECTION_XML, &err);
+ if (!m->node) {
+ _ERR("failed to new xml %s", err->message);
+ g_error_free(err);
+ return false;
+ }
+
+ if (!m->node->interfaces) {
+ _ERR("no interface received");
+ goto unref_node;
+ }
+
+ m->owner_id = g_bus_own_name(m->info.bus_type, m->info.name,
G_BUS_NAME_OWNER_FLAGS_NONE,
sm_CbHandlerBusAcquired,
sm_CbHandlerNameAcquired,
- sm_CbHandlerNameLost, this, NULL))
-
- _CHECK_FAIL{ /* */ }
- _CHECK_FAIL{ /* */ }
- _CHECK_FAIL{ g_object_unref(m->node); }
- } _CREATE_END_AND_CATCH{ if (err) { _ERR("ERR: %s", err->message); g_error_free(err); } return false; }
+ sm_CbHandlerNameLost, this, NULL);
+ if (!m->owner_id) {
+ _ERR("bus own name failed");
+ goto unref_node;
+ }
return true;
+
+unref_node:
+ g_object_unref(m->node);
+
+ return false;
}
@@ -190,33 +203,54 @@ void CBaseBus::m_Destroy(void)
}
-bool CBaseBus::Create(const SCallback *callback, const char *szName, const char *szObjectPath, const char *szInterfaceName, int nBusType)
+bool CBaseBus::Create(const SCallback *callback, const char *szName,
+ const char *szObjectPath, const char *szInterfaceName, int nBusType)
{
ASSERT(!m);
- _CREATE_BEGIN{
- _CHECK(m = new SBaseBus);
- _CHECK(m->info.name = new char[strlen(szName) + 1]);
- _CHECK(m->info.object_path = new char[strlen(szObjectPath) + 1]);
- _CHECK(m->info.interface_name = new char[strlen(szInterfaceName) + 1]);
- _COMMAND{
- m->info.bus_type = (GBusType)nBusType;
- strcpy(m->info.name, szName);
- strcpy(m->info.object_path, szObjectPath);
- strcpy(m->info.interface_name, szInterfaceName);
- }
- _CHECK(m_Create());
-
- _CHECK_FAIL{ m_Destroy(); }
- _CHECK_FAIL{ delete[] m->info.interface_name; }
- _CHECK_FAIL{ delete[] m->info.object_path; }
- _CHECK_FAIL{ delete[] m->info.name; }
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
+ m = new SBaseBus;
+ if (!m) {
+ _ERR("failed to create SBaseBus");
+ return false;
+ }
+
+ m->info.name = new char[strlen(szName) + 1];
+ if (!m->info.name)
+ goto del_m;
+
+ m->info.object_path = new char[strlen(szObjectPath) + 1];
+ if (!m->info.object_path) {
+ delete[] m->info.name;
+ goto del_m;
+ }
+
+ m->info.interface_name = new char[strlen(szInterfaceName) + 1];
+ if (!m->info.interface_name) {
+ delete[] m->info.object_path;
+ delete[] m->info.name;
+ goto del_m;
+ }
+
+ m->info.bus_type = (GBusType)nBusType;
+ strcpy(m->info.name, szName);
+ strcpy(m->info.object_path, szObjectPath);
+ strcpy(m->info.interface_name, szInterfaceName);
+
+ if (!m_Create()) {
+ delete[] m->info.interface_name;
+ delete[] m->info.object_path;
+ delete[] m->info.name;
+ goto del_m;
+ }
m->cb = *callback;
return true;
+del_m:
+ delete m;
+ m = NULL;
+
+ return false;
}
diff --git a/src/engine.cpp b/src/engine.cpp
index 79399f1..0eab78a 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -244,25 +244,40 @@ CEngineBarItem *CEngineBarItem::Alloc(JsonReader *reader, int idx)
gint64 r, g, b;
gint64 column;
- _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; }
+ if (!json_reader_read_element(reader, idx)) {
+ _ERR("Cannot read element of index %d", idx);
+ return NULL;
+ }
+
+ it = new CEngineBarItem;
+ if (!it) {
+ json_reader_end_element(reader);
+ 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);
noctnt_title = _read_attr(reader, ATTR_NOCTNT_TITLE);
@@ -289,6 +304,11 @@ CEngineBarItem *CEngineBarItem::Alloc(JsonReader *reader, int idx)
it->SetInt(VINT_COLUMN, column);
return it;
+err:
+ json_reader_end_element(reader);
+ delete it;
+
+ return NULL;
}
bool CEngine::_load_bar_items(JsonReader *reader)
@@ -748,10 +768,12 @@ bool CEngine::m_OnAddContents(Eina_List *list)
EINA_LIST_FOREACH(m->hbar_its, ll, obj) {
hit = (CEngineBarItem *)obj;
- if (!strcmp(hit->Str(CEngineBarItem::VSTR_SVC_ID), content->svcid)) {
+ if (!strcmp(hit->Str(CEngineBarItem::VSTR_SVC_ID),
+ content->svcid)) {
_add_dbar_item(hit, CEngineDBarItem::STYLE_CONTENT,
content->title, content, 1,
- content->action, content->actor, content->args);
+ content->action, content->actor,
+ content->args);
}
}
}
@@ -768,7 +790,8 @@ static void _get_item_bg_and_icon(enum CBus::EPinType type, const char *icon,
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);
+ it->SetStr(CEngineBarItem::VSTR_ICON_FOCUS,
+ DEF_PIN_ITEM_CHANNEL_ICON_FOCUS);
break;
case CBus::PIN_TYPE_PACKAGE:
it->SetColor(ITEM_PACKAGE_BG_R, ITEM_PACKAGE_BG_G, ITEM_PACKAGE_BG_B);
@@ -777,14 +800,16 @@ static void _get_item_bg_and_icon(enum CBus::EPinType type, const char *icon,
it->SetStr(CEngineBarItem::VSTR_ICON_FOCUS, icon);
} else {
it->SetStr(CEngineBarItem::VSTR_ICON, DEF_PIN_ITEM_DEFAULT_ICON);
- it->SetStr(CEngineBarItem::VSTR_ICON_FOCUS, DEF_PIN_ITEM_DEFAULT_ICON_FOCUS);
+ it->SetStr(CEngineBarItem::VSTR_ICON_FOCUS,
+ DEF_PIN_ITEM_DEFAULT_ICON_FOCUS);
}
it->SetType(CAppContentFavorite::TYPE_APPS);
break;
default:
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);
+ it->SetStr(CEngineBarItem::VSTR_ICON_FOCUS,
+ DEF_PIN_ITEM_DEFAULT_ICON_FOCUS);
break;
}
}
@@ -957,7 +982,6 @@ bool CEngine::m_OnDelAll(const char *svcid, bool reload)
if (reload) {
_del_pin_item(EINA_TRUE);
-
InvokeUpdateCallback();
return true;
}
@@ -966,12 +990,54 @@ bool CEngine::m_OnDelAll(const char *svcid, bool reload)
hit = (CEngineBarItem *)obj;
if (strcmp(hit->Str(CEngineBarItem::VSTR_SVC_ID), svcid))
continue;
+
return _del_dbar_item_all(hit);
}
return false;
}
+bool CEngine::m_CreateAppContents(void)
+{
+ m->pAppContentFavorite = new CAppContentFavorite;
+ if (!m->pAppContentFavorite)
+ return false;
+
+ if (!m->pAppContentFavorite->Create(NULL)) {
+ delete m->pAppContentFavorite;
+ return false;
+ }
+
+ m->pAppContentHistory = new CAppContentHistory;
+ if (!m->pAppContentHistory)
+ goto fav_err;
+
+ if (!m->pAppContentHistory->Create(NULL)) {
+ delete m->pAppContentHistory;
+ goto fav_err;
+ }
+
+ m->pAppContentPin = new CAppContentPin;
+ if (!m->pAppContentPin)
+ goto history_err;
+
+ if (!m->pAppContentPin->Create(NULL)) {
+ delete m->pAppContentPin;
+ goto history_err;
+ }
+
+ return true;
+
+history_err:
+ m->pAppContentHistory->Destroy();
+ delete m->pAppContentHistory;
+fav_err:
+ m->pAppContentFavorite->Destroy();
+ delete m->pAppContentFavorite;
+
+ return false;
+}
+
bool CEngine::Create(void)
{
ASSERT(!m);
@@ -988,34 +1054,41 @@ bool CEngine::Create(void)
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(m->pAppContentFavorite = new CAppContentFavorite);
- _CHECK(m->pAppContentFavorite->Create(NULL));
- _CHECK(m->pAppContentHistory = new CAppContentHistory);
- _CHECK(m->pAppContentHistory->Create(NULL));
- _CHECK(m->pAppContentPin = new CAppContentPin);
- _CHECK(m->pAppContentPin->Create(NULL));
-
-
- _CHECK_FAIL{ m->pAppContentPin->Destroy(); }
- _CHECK_FAIL{ delete m->pAppContentPin; }
- _CHECK_FAIL{ m->pAppContentHistory->Destroy(); }
- _CHECK_FAIL{ delete m->pAppContentHistory; }
- _CHECK_FAIL{ m->pAppContentFavorite->Destroy(); }
- _CHECK_FAIL{ delete m->pAppContentFavorite; }
- _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; }
+ m = new SEngine;
+ if (!m)
+ return false;
+
+ if (!m_LoadUser())
+ goto err1;
+
+ if (!m_LoadItemConfig()) {
+ m_UnloadConfig();
+ goto err1;
+ }
+
+ m->bus = new CBus;
+ if (!m->bus) {
+ m_UnloadConfig();
+ goto err1;
+ }
+
+ if (!m->bus->Create(&cb))
+ goto err2;
+
+ if (!m_CreateAppContents()) {
+ m->bus->Destroy();
+ goto err2;
+ }
return true;
+err2:
+ delete m->bus;
+ m_UnloadConfig();
+err1:
+ delete m;
+ m = NULL;
+
+ return false;
}
void CEngine::Destroy(void)
@@ -1140,7 +1213,8 @@ bool CEngine::Delete(CEngineUBarItem *it, const char *password)
EINA_LIST_FOREACH(m->ubar_its, l, obj) {
_it = (CEngineUBarItem *)obj;
- if (strcmp(_it->Str(CEngineUBarItem::VSTR_NAME), it->Str(CEngineUBarItem::VSTR_NAME)))
+ if (strcmp(_it->Str(CEngineUBarItem::VSTR_NAME),
+ it->Str(CEngineUBarItem::VSTR_NAME)))
continue;
m->ubar_its = eina_list_remove_list(m->ubar_its, l);
@@ -1187,7 +1261,8 @@ bool CEngine::DelPin(CEngineBarItem *it)
if (!it)
return false;
- if (!m->pAppContentPin->Remove(it->Type(), it->Str(CEngineBarItem::VSTR_PIN_ID))) {
+ if (!m->pAppContentPin->Remove(it->Type(),
+ it->Str(CEngineBarItem::VSTR_PIN_ID))) {
_ERR("failed to unset pin item");
return false;
}
@@ -1200,7 +1275,8 @@ bool CEngine::DelPin(CEngineBarItem *it)
if (!hit->Str(CEngineBarItem::VSTR_PIN_ID))
continue;
- if (!strcmp(hit->Str(CEngineBarItem::VSTR_PIN_ID), it->Str(CEngineBarItem::VSTR_PIN_ID))) {
+ 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;
@@ -1222,13 +1298,16 @@ bool CEngine::Swap(CEngineBarItem *it1, CEngineBarItem *it2)
ASSERT(it1);
ASSERT(it2);
- if (!it1->Str(CEngineBarItem::VSTR_PIN_ID) || !it2->Str(CEngineBarItem::VSTR_PIN_ID)) {
+ if (!it1->Str(CEngineBarItem::VSTR_PIN_ID) ||
+ !it2->Str(CEngineBarItem::VSTR_PIN_ID)) {
_ERR("No pin item");
return false;
}
- if (!m->pAppContentPin->Swap(it1->Type(), (char *)it1->Str(CEngineBarItem::VSTR_PIN_ID),
- it2->Type(), (char *)it2->Str(CEngineBarItem::VSTR_PIN_ID))) {
+ if (!m->pAppContentPin->Swap(it1->Type(),
+ (char *)it1->Str(CEngineBarItem::VSTR_PIN_ID),
+ it2->Type(),
+ (char *)it2->Str(CEngineBarItem::VSTR_PIN_ID))) {
_ERR("failed to swap content");
return false;
}
diff --git a/src/engine.h b/src/engine.h
index dd090cd..dc729f5 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -76,6 +76,7 @@ private:
bool m_LoadUser(void);
bool m_LoadItemConfig(void);
void m_UnloadConfig(void);
+ bool m_CreateAppContents(void);
public:
CEngine() : m(0) {}
virtual ~CEngine() {}