Support synchronous connection requests 56/240956/2
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 13 Aug 2020 06:22:17 +0000 (15:22 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 13 Aug 2020 06:24:27 +0000 (15:24 +0900)
Change-Id: I03d0d7435c0f019864b57e44eb74f81a184c0bbf
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
idlc/gen/c_proxy_body_gen.cc
idlc/gen/c_proxy_body_gen.h
idlc/gen/c_proxy_body_gen_cb.h
idlc/gen/c_proxy_header_gen.cc
idlc/gen/c_proxy_header_gen.h
idlc/gen/c_proxy_header_gen_cb.h
idlc/gen/cpp_proxy_body_gen_cb.h
idlc/gen/cpp_proxy_header_gen_cb.h
idlc/gen/cs_proxy_gen.cc
idlc/gen/cs_proxy_gen_cb.h

index 54df1c8ea0e6861c2d59fdff98946c963e3c73e8..3e27f6cfed5c552e1829a3fc7b077647bc53dd37 100644 (file)
@@ -76,6 +76,7 @@ void CProxyBodyGen::GenInterface(std::ofstream& stream, const Interface& inf) {
   GenInterfaceCtor(stream, inf);
   GenInterfaceConnect(stream, inf);
   GenInterfaceDtor(stream, inf);
+  GenInterfaceConnectSync(stream, inf);
 }
 
 void CProxyBodyGen::GenInterfaceFileSharing(std::ofstream& stream,
@@ -449,6 +450,12 @@ void CProxyBodyGen::GenInterfaceDtor(std::ofstream& stream,
       GetInterfaceIdWithNamespace(inf)));
 }
 
+void CProxyBodyGen::GenInterfaceConnectSync(std::ofstream& stream,
+                                            const Interface& inf) {
+  stream << SmartIndent(ReplaceAll(CB_INTERFACE_CONNECT_SYNC, "##",
+      GetInterfaceIdWithNamespace(inf)));
+}
+
 std::string CProxyBodyGen::GetMethodWriteString(const Interface& inf,
                                                 const Declaration& decl) {
   const char setter[] = "$$($$, $$);\n";
index 815f41852c6fd1e925a80fc4816bf058f7c3ac7a..a89c6020f69f501dc7153ff6d7d830586b1644d7 100644 (file)
@@ -60,6 +60,7 @@ class CProxyBodyGen : public CBodyGeneratorBase {
   void GenInterfaceCtor(std::ofstream& stream, const Interface& inf);
   void GenInterfaceConnect(std::ofstream& stream, const Interface& inf);
   void GenInterfaceDtor(std::ofstream& stream, const Interface& inf);
+  void GenInterfaceConnectSync(std::ofstream& stream, const Interface& inf);
 
  private:
   void GenInterfaceDelegator(std::ofstream& stream, const std::string& id,
index a8717df770bfe01427142ed6648cca2762b50523..0757b2d975f34607c8b4b7da14c06db038ac3667 100644 (file)
@@ -560,4 +560,25 @@ R"__c_cb(
        }
 )__c_cb";
 
+const char CB_INTERFACE_CONNECT_SYNC[] =
+R"__c_cb(
+int rpc_port_proxy_##_connect_sync(rpc_port_proxy_##_h h)
+{
+    int r;
+
+    if (!h || !h->proxy) {
+        _E("Invalid parameter");
+        return -1;
+    }
+
+    r = rpc_port_proxy_connect_sync(h->proxy, h->stub_appid, "##");
+    if (r != 0) {
+        _E("Failed to connect sync ##(%s)", h->stub_appid);
+        return r;
+    }
+
+    return 0;
+}
+)__c_cb";
+
 #endif  // IDLC_C_GEN_C_PROXY_BODY_GEN_CB_H_
index 64bfab4c0df70392fe5a55108371fee854340d74..b5bca942a493932f75bf9f7ce85b3cb1a6d25f95 100644 (file)
@@ -56,6 +56,7 @@ void CProxyHeaderGen::GenInterface(std::ofstream& stream,
   GenInterfaceConnect(stream, inf);
   GenInterfaceDtor(stream, inf);
   GenInterfaceMethods(stream, inf);
+  GenInterfaceConnectSync(stream, inf);
 }
 
 void CProxyHeaderGen::GenInterfaceDelegators(std::ofstream& stream,
@@ -165,4 +166,10 @@ void CProxyHeaderGen::GenInterfaceDtor(std::ofstream& stream,
       GetInterfaceIdWithNamespace(inf));
 }
 
+void CProxyHeaderGen::GenInterfaceConnectSync(std::ofstream& stream,
+                                              const Interface& inf) {
+  stream << ReplaceAll(CB_INTERFACE_CONNECT_SYNC, "##",
+      GetInterfaceIdWithNamespace(inf));
+}
+
 }  // namespace tidl
index 800d67ec30ed802b255442dede6bf9d4fe9cd25d..8dfa891f64a4deecb30205c1dfbb199d98c4886d 100644 (file)
@@ -43,6 +43,7 @@ class CProxyHeaderGen : public CHeaderGeneratorBase {
   void GenInterfaceCtor(std::ofstream& stream, const Interface& inf);
   void GenInterfaceConnect(std::ofstream& stream, const Interface& inf);
   void GenInterfaceDtor(std::ofstream& stream, const Interface& inf);
+  void GenInterfaceConnectSync(std::ofstream& stream, const Interface& inf);
 
  private:
   void GenInterfaceDelegator(std::ofstream& stream, const std::string& id,
index 4fe6dafe850cd4fa7a459dbd35e3f604ba0b7981..e6849e1ad8e6cb5ba25e3048c732bb8afae9dc25 100644 (file)
@@ -70,4 +70,9 @@ R"__c_cb(
 int rpc_port_##_destroy(rpc_port_##_h delegate);
 )__c_cb";
 
+const char CB_INTERFACE_CONNECT_SYNC[] =
+R"__c_cb(
+int rpc_port_proxy_##_connect_sync(rpc_port_proxy_##_h h);
+)__c_cb";
+
 #endif  // IDLC_C_GEN_C_PROXY_HEADER_GEN_CB_H_
index b5dbefd9acc1d8dd12371e8d6a5f1b3fe2034d8d..83a9f084c9eccff8fc1ca05b40ed3967e0ccafe9 100644 (file)
@@ -64,8 +64,12 @@ R"__cpp_cb(
 
 const char CB_PROXY_HELPER_METHODS[] =
 R"__cpp_cb(
-void ##::Connect() {
-  int ret = rpc_port_proxy_connect(proxy_, target_appid_.c_str(), "##");
+void ##::Connect(bool sync) {
+  int ret;
+  if (sync)
+    ret = rpc_port_proxy_connect_sync(proxy_, target_appid_.c_str(), "##");
+  else
+    ret = rpc_port_proxy_connect(proxy_, target_appid_.c_str(), "##");
   if (ret != RPC_PORT_ERROR_NONE) {
     _E("Failed to connect ##");
     switch (ret) {
index 0bf19ee47f9f42433caab044211e9b3104f1b472..aea484f1fbc946511d8aa99abda339b6df0b9cda 100644 (file)
@@ -64,6 +64,7 @@ R"__cpp_cb(
   /// </summary>
   /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
   /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+  //  <param name="sync">if true, connects to the service app synchornously</param>
   /// <exception cref="InvalidIDException">
   /// Thrown when the appid to connect is invalid.
   /// </exception>
@@ -74,7 +75,7 @@ R"__cpp_cb(
   /// Thrown when the permission is denied.
   /// </exception>
   /// <remark> If you want to use this method, you must add privileges.</remark>
-  void Connect();
+  void Connect(bool sync = false);
 
   /// <summary>
   /// Disposes delegate objects in this interface
index a45874a9d98214f769e61484fa8cd126a6de4861..3b96d03198d627fb0e7499bb7f48ad293bf67461 100644 (file)
@@ -92,6 +92,9 @@ void CsProxyGen::GenCtor(std::ofstream& stream, const Interface& iface) {
 void CsProxyGen::GenConnectMethod(std::ofstream& stream,
     const Interface& iface) {
   GenTemplate(CB_CONNECT_METHOD, stream,
+    [&]()->std::string {
+      return iface.GetID();
+    },
     [&]()->std::string {
       return iface.GetID();
     });
index f1e4743db1f7914b4405a0815318d0560b4470cb..21e25b9188caea14172477d71586f5637c0e03fb 100644 (file)
@@ -124,6 +124,26 @@ R"__cs_cb(
                 Connect(_appId, "$$");
             }
 
+            /// <summary>
+            /// Connects to the service app synchronously.
+            /// </summary>
+            /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+            /// <privilege>http://tizen.org/privilege/datasharing</privilege>
+            /// <exception cref="InvalidIDException">
+            /// Thrown when the appid to connect is invalid.
+            /// </exception>
+            /// <exception cref="InvalidIOException">
+            /// Thrown when internal I/O error happen.
+            /// </exception>
+            /// <exception cref="PermissionDeniedException">
+            /// Thrown when the permission is denied.
+            /// </exception>
+            /// <remark> If you want to use this method, you must add privileges.</remark>
+            public void ConnectSync()
+            {
+                ConnectSync(_appId, "$$");
+            }
+
             /// <summary>
             /// Disposes delegate objects in this interface
             /// </summary>