+ return infoPtr;
+}
+
+std::string BoxDaemonImpl::getBoxIdFromService(service_h service)
+{
+ LogD("enter");
+
+ int ret;
+ char* serviceUri = NULL;
+ ret = service_get_uri(service, &serviceUri);
+ if (ret != SERVICE_ERROR_NONE) {
+ LogD("no box uri");
+ return std::string();
+ }
+
+ std::string uri(serviceUri);
+ delete[] serviceUri;
+
+ if(uri.compare(0, BOX_SERVICE_SCHEME.size(), BOX_SERVICE_SCHEME)) {
+ // uri is not box-service scheme
+ return std::string();
+ }
+
+ std::string boxId = uri.substr(BOX_SERVICE_SCHEME.size());
+ return boxId;
+}
+
+bool BoxDaemonImpl::isServiceCallerBoxOwner(service_h service)
+{
+ LogD("enter");
+
+ int ret;
+
+ std::string boxId = getBoxIdFromService(service);
+ if (boxId.empty()) {
+ LogD("error box-id");
+ return false;
+ }
+
+ // check if caller is owner of this box
+ const char* appId = web_provider_livebox_get_app_id(boxId.c_str());
+ if (!appId) {
+ return false;
+ }
+ std::string ownerAppId(appId);
+ delete[] appId;
+
+ char* caller = NULL;
+ ret = service_get_caller(service, &caller);
+ if (ret != SERVICE_ERROR_NONE) {
+ ret = service_get_extra_data(
+ service, ALARM_CALLER_KEY.c_str(), &caller);
+ if (ret != SERVICE_ERROR_NONE) {
+ LogD("failed to get caller's appid from service");
+ return false;
+ }
+ }
+ std::string callerAppId(caller);
+
+ // release strings
+ delete[] caller;
+
+ if (ownerAppId != callerAppId) {
+ LogD("caller is not matched with owner of requested box");
+ return false;
+ }
+
+ return true;
+}
+
+BoxInfoPtr BoxDaemonImpl::handleOperationUpdate(service_h service)
+{
+ LogD("enter");
+
+ int ret;
+
+ if (!isServiceCallerBoxOwner(service)) {
+ return BoxInfoPtr();
+ }
+
+ std::string boxId = getBoxIdFromService(service);
+ if (boxId.empty()) {
+ LogD("error box-id");
+ return BoxInfoPtr();
+ }
+
+ char* contentInfo = NULL;
+ service_get_extra_data(service, CONTENT_INFO_KEY.c_str(), &contentInfo);
+
+ std::string type(getBoxType(boxId.c_str()));
+ if (type.empty()) {
+ LogD("no type for this box");
+ delete[] contentInfo;
+ return BoxInfoPtr();
+ }
+ BoxInfoPtr info = BoxInfoPtr(new BoxInfo(type, boxId, ""));
+ if (contentInfo) {
+ info->contentInfo = std::string(contentInfo);
+ }
+
+ // release string
+ delete[] contentInfo;
+
+ return info;