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 54df1c8..3e27f6c 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 815f418..a89c602 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 a8717df..0757b2d 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 64bfab4..b5bca94 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 800d67e..8dfa891 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 4fe6daf..e6849e1 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 b5dbefd..83a9f08 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 0bf19ee..aea484f 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 a45874a..3b96d03 100644 (file)
@@ -94,6 +94,9 @@ void CsProxyGen::GenConnectMethod(std::ofstream& stream,
   GenTemplate(CB_CONNECT_METHOD, stream,
     [&]()->std::string {
       return iface.GetID();
+    },
+    [&]()->std::string {
+      return iface.GetID();
     });
   stream << NLine(1);
 }
index f1e4743..21e25b9 100644 (file)
@@ -125,6 +125,26 @@ R"__cs_cb(
             }
 
             /// <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>
             /// <param name="tag">The tag string from delegate object</param>