From a04aa40a6b87a470c3259e6f75318e763d6de8ea Mon Sep 17 00:00:00 2001 From: Soohye Shin Date: Tue, 21 Apr 2015 11:44:07 +0900 Subject: [PATCH] add BUS_METHOD_SEND_ACTION method sending function Change-Id: Ie411b1c099968c5e48a5f924c780b2290374e38c Signed-off-by: Soohye Shin --- src/ClientBus.cpp | 44 ++++++++++++++++++++++++++++++++++++++ src/ClientBus.h | 8 ++++++- src/engine.cpp | 1 + src/engine/include/EngineBarItem.h | 5 +++-- src/engine/src/EngineBarItem.cpp | 17 ++++++++++++--- src/engine/src/EngineDBarItem.cpp | 4 ++-- 6 files changed, 71 insertions(+), 8 deletions(-) diff --git a/src/ClientBus.cpp b/src/ClientBus.cpp index 0e43b6e..bb112b0 100644 --- a/src/ClientBus.cpp +++ b/src/ClientBus.cpp @@ -183,6 +183,43 @@ void CClientBus::m_Send(void) -1, m->cancellable, sm_CbSend, this); } +bool CClientBus::m_ActionSend(CAppContentProvider::EMethodActionType type, const char *args) +{ + ASSERT(m); + + if (!m->proxy) + return false; + + m->cancellable = g_cancellable_new(); + if (!m->cancellable) { + _ERR("cancellable new failed"); + return false; + } + + GVariant *param; + GVariantBuilder *builder; + + builder = g_variant_builder_new(G_VARIANT_TYPE_TUPLE); + if (!builder) { + _ERR("builder new failed"); + return false; + } + + g_variant_builder_add(builder, "s", m->svcid); + g_variant_builder_add(builder, "y", type); + g_variant_builder_add(builder, "s", args ? args : ""); + + param = g_variant_builder_end(builder); + + g_variant_builder_unref(builder); + + g_dbus_proxy_call(m->proxy, BUS_METHOD_SEND_ACTION, + param, G_DBUS_CALL_FLAGS_NO_AUTO_START, + -1, m->cancellable, sm_CbSend, this); + + return true; +} + /** * Invoked when proxy is ready successfully. * @@ -268,3 +305,10 @@ void CClientBus::SendSvcid(void) BUS_INTERFACE, NULL, sm_CbProxy, this); } + +bool CClientBus::SendAction(CAppContentProvider::EMethodActionType type, const char *args) +{ + ASSERT(FlagCreate()); + + return m_ActionSend(type, args); +} diff --git a/src/ClientBus.h b/src/ClientBus.h index 0f2637c..6d4da49 100644 --- a/src/ClientBus.h +++ b/src/ClientBus.h @@ -20,6 +20,7 @@ #include #include +#include class CTimeout { @@ -54,6 +55,7 @@ private: void m_OnSend(GObject *sobj, GAsyncResult *res); void m_Send(void); + bool m_ActionSend(CAppContentProvider::EMethodActionType type, const char *args); protected: virtual void t_OnTimeout(void); @@ -71,7 +73,11 @@ public: //! Sends service id to client daemons as creating proxy to bus. void SendSvcid(void); + + //! Sends Action to client daemons + bool SendAction(CAppContentProvider::EMethodActionType type, const char *args); + }; -#endif /* __CLIENT_BUS_H__ */ \ No newline at end of file +#endif /* __CLIENT_BUS_H__ */ diff --git a/src/engine.cpp b/src/engine.cpp index b30bfe0..6f96a7b 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -334,6 +334,7 @@ bool CEngine::_load_bar_items(JsonReader *reader) delete cbus; continue; } + it->SetCBus(cbus); cbus->SendSvcid(); m->client_buslist = eina_list_append(m->client_buslist, cbus); diff --git a/src/engine/include/EngineBarItem.h b/src/engine/include/EngineBarItem.h index 3b99481..24fb3ad 100644 --- a/src/engine/include/EngineBarItem.h +++ b/src/engine/include/EngineBarItem.h @@ -20,7 +20,7 @@ #include #include "Entity.h" - +#include "../../ClientBus.h" class CEngineDBarItem; @@ -55,6 +55,7 @@ public: virtual ~CEngineBarItem(); void SetEngine(CEngine *eng); + void SetCBus(CClientBus *cbus); void SetCtntId(int id); int CtntId(void); @@ -77,7 +78,7 @@ public: bool RemoveDBar(int ctnt_id); bool AddHistory(CAppContent::EType type, const char *id); - bool DelHistory(CAppContent::EType type, const char *id); + bool DelHistory(const char *id); bool DelAllHistory(void); static CEngineBarItem *Alloc(JsonReader *reader, int idx); diff --git a/src/engine/src/EngineBarItem.cpp b/src/engine/src/EngineBarItem.cpp index 4c39f95..49fd650 100644 --- a/src/engine/src/EngineBarItem.cpp +++ b/src/engine/src/EngineBarItem.cpp @@ -20,14 +20,17 @@ #include #include +#include #include #include "../../engine.h" +#include "../../ClientBus.h" #include "../include/EngineBarItem.h" struct SEngineBarItem { CEngine *eng; + CClientBus *cbus; int r; int g; @@ -57,6 +60,14 @@ CEngineBarItem::~CEngineBarItem() } +void CEngineBarItem::SetCBus(CClientBus *cbus) +{ + ASSERT(m); + + m->cbus = cbus; +} + + void CEngineBarItem::SetEngine(CEngine *eng) { ASSERT(m); @@ -231,18 +242,18 @@ bool CEngineBarItem::RemoveDBar(int ctnt_id) return false; } -bool CEngineBarItem::DelHistory(CAppContent::EType type, const char *id) +bool CEngineBarItem::DelHistory(const char *id) { ASSERT(m); - return m->eng->DelHistory(type, id); + return m->cbus->SendAction(CAppContentProvider::METHOD_ACTION_HISTORY_DEL, id); } bool CEngineBarItem::DelAllHistory(void) { ASSERT(m); - return m->eng->DelAllHistory(); + return m->cbus->SendAction(CAppContentProvider::METHOD_ACTION_HISTORY_DEL_ALL, NULL); } bool CEngineBarItem::AddHistory(CAppContent::EType type, const char *id) diff --git a/src/engine/src/EngineDBarItem.cpp b/src/engine/src/EngineDBarItem.cpp index 79a2a50..79a248b 100644 --- a/src/engine/src/EngineDBarItem.cpp +++ b/src/engine/src/EngineDBarItem.cpp @@ -165,7 +165,7 @@ bool CEngineDBarItem::Del(CEngineDBarItemContent::EType type) svcid = bundle_get_val(args, "svcid"); - if (!m->parent->DelHistory(CAppContent::TYPE_CHANNEL, svcid)) { + if (!m->parent->DelHistory(svcid)) { _ERR("failed to delete history"); bundle_free(args); return false; @@ -173,7 +173,7 @@ bool CEngineDBarItem::Del(CEngineDBarItemContent::EType type) bundle_free(args); } else { - if (!m->parent->DelHistory(CAppContent::TYPE_APPS, Str(VSTR_ACTOR))) { + if (!m->parent->DelHistory(Str(VSTR_ACTOR))) { _ERR("failed to delete history"); return false; } -- 2.7.4