BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(alarm-service)
BuildRequires: pkgconfig(cynara-creds-gdbus)
BuildRequires: pkgconfig(cynara-client)
* limitations under the License.
*/
+#include <fstream>
+#include <aul.h>
#include "Credential.h"
#include "ServiceRunner.h"
#include "ServiceClient.h"
+#define BUFFER_SIZE 256
+
using namespace ctx;
ServiceClient::ServiceClient(ServiceRunner* runner, const std::string& busName) :
__methodCallHandler = handler;
}
-const std::string& ServiceClient::getBusName()
+const std::string& ServiceClient::getName()
{
- return __busName;
+ if (!__name.empty())
+ return __name;
+
+ char buffer[BUFFER_SIZE];
+
+ // Package ID
+ int err = aul_app_get_pkgid_bypid_for_uid(__credential->getPid(), buffer, BUFFER_SIZE, __credential->getUid());
+ if (IS_SUCCESS(err)) {
+ __name = buffer;
+ _I("PkgId: %s", __name.c_str());
+ return __name;
+ }
+
+ // Executable Path
+ char path[32];
+ g_snprintf(path, 32, "/proc/%d/cmdline", __credential->getPid());
+
+ std::ifstream cmdfile(path);
+ std::string cmdline;
+
+ if (std::getline(cmdfile, cmdline)) {
+ __name = cmdline;
+ _I("cmd: %s", __name.c_str());
+ return __name;
+ }
+
+ _E("Failed to get the client's name");
+ return __name;
}
-const std::string& ServiceClient::getId()
+const std::string& ServiceClient::getSecurityLabel()
{
return __credential->getClientId();
}
+const std::string& ServiceClient::getBusName()
+{
+ return __busName;
+}
+
uid_t ServiceClient::getUid()
{
return __credential->getUid();
void setHandler(IMethodCallHandler* handler);
+ const std::string& getName();
+ const std::string& getSecurityLabel();
const std::string& getBusName();
- const std::string& getId();
uid_t getUid();
bool isSystem();
ServiceRunner* __serviceRunner;
IMethodCallHandler* __methodCallHandler;
+ std::string __name;
std::string __busName;
Credential* __credential;
};