Move function definition to aul header
[platform/core/appfw/aul-1.git] / src / aul_svc.cc
index 72b9673..389dc50 100644 (file)
@@ -1233,6 +1233,58 @@ extern "C" API void aul_svc_free_appid_array(char** appid_array,
   free(appid_array);
 }
 
+extern "C" API int aul_svc_set_window_position(bundle* b,
+    int x, int y, int w, int h) {
+  if (b == nullptr) {
+    _E("Invalid parameter");
+    return AUL_SVC_RET_EINVAL;
+  }
+
+  ::SetBundle(b, AUL_K_HINT_SCREEN_POS_X, std::to_string(x).c_str());
+  ::SetBundle(b, AUL_K_HINT_SCREEN_POS_Y, std::to_string(y).c_str());
+  ::SetBundle(b, AUL_K_HINT_SCREEN_WIDTH, std::to_string(w).c_str());
+  ::SetBundle(b, AUL_K_HINT_SCREEN_HEIGHT, std::to_string(h).c_str());
+
+  return AUL_SVC_RET_OK;
+}
+
+extern "C" API int aul_svc_get_window_position(bundle* b,
+    int* x, int* y, int* w, int* h) {
+  if (b == nullptr ||
+      x == nullptr ||
+      y == nullptr ||
+      w == nullptr ||
+      h == nullptr) {
+    _E("Invalid parameter");
+    return AUL_SVC_RET_EINVAL;
+  }
+
+  char* x_str = nullptr;
+  char* y_str = nullptr;
+  char* w_str = nullptr;
+  char* h_str = nullptr;
+
+  bundle_get_str(b , AUL_K_HINT_SCREEN_POS_X, &x_str);
+  bundle_get_str(b , AUL_K_HINT_SCREEN_POS_Y, &y_str);
+  bundle_get_str(b , AUL_K_HINT_SCREEN_WIDTH, &w_str);
+  bundle_get_str(b , AUL_K_HINT_SCREEN_HEIGHT, &h_str);
+
+  if (x_str == nullptr ||
+      y_str == nullptr ||
+      w_str == nullptr ||
+      h_str == nullptr) {
+    _E("failed to get position");
+    return AUL_SVC_RET_ERROR;
+  }
+
+  *x = atoi(x_str);
+  *y = atoi(y_str);
+  *w = atoi(w_str);
+  *h = atoi(h_str);
+
+  return AUL_SVC_RET_OK;
+}
+
 extern "C" API int aul_svc_set_defapp(const char* op, const char* mime_type,
     const char* uri, const char* defapp) {
   DEPRECATION_WARNING();