Refactor java generator 88/265488/7
authorjh9216.park <jh9216.park@samsung.com>
Wed, 20 Oct 2021 11:37:00 +0000 (07:37 -0400)
committerjh9216.park <jh9216.park@samsung.com>
Thu, 21 Oct 2021 03:12:50 +0000 (23:12 -0400)
- Add API descriptions in generated classes
- Add missed methods

Change-Id: I179192707910b1ff503fa2b09debbca28e53a4b0
Signed-off-by: jh9216.park <jh9216.park@samsung.com>
idlc/gen_cion/java_cion_gen_base.cc
idlc/gen_cion/java_cion_gen_cb.h
idlc/gen_cion/java_cion_proxy_gen.cc
idlc/gen_cion/java_cion_proxy_gen_cb.h
idlc/gen_cion/java_cion_structure_gen.cc
idlc/gen_cion/java_cion_stub_gen_cb.h

index b0eda5dba7d43fc9e867257d2aa8e610d9d306ff..3ba497a5b44659cf53eaa5f4f1efb3c5f9256981 100644 (file)
@@ -69,16 +69,15 @@ JavaCionGeneratorBase::JavaCionGeneratorBase(std::shared_ptr<Document> doc)
 void JavaCionGeneratorBase::GenMethodId(std::ofstream& stream,
     const Interface& iface) {
   int cnt = 2;
-  stream << Tab(1) << "public static final int __RESULT = 0;" << NLine(1);
-  stream << Tab(1) << "public static final int __CALLBACK = 1;" << NLine(1);
+  stream << Tab(1) << "public static final int __RESULT = 0;" << NLine(2);
+  stream << Tab(1) << "public static final int __CALLBACK = 1;" << NLine(2);
   for (auto& i : iface.GetDeclarations().GetDecls()) {
     if (i->GetMethodType() == Declaration::MethodType::DELEGATE)
       continue;
     stream << Tab(1)
             << "public static final int __"
-            << i->GetID() << " = " << cnt++ << ";" << NLine(1);
+            << i->GetID() << " = " << cnt++ << ";" << NLine(2);
   }
-  stream << NLine(1);
 }
 
 void JavaCionGeneratorBase::GenDeclaration(std::ofstream& stream,
@@ -613,9 +612,8 @@ void JavaCionGeneratorBase::GenDelegateId(std::ofstream& stream,
       if (i->GetMethodType() != Declaration::MethodType::DELEGATE)
         continue;
       stream << Tab(1) << "private static final int __"
-              << i->GetID() << " = " << cnt++ << ";" << NLine(1);
+              << i->GetID() << " = " << cnt++ << ";" << NLine(2);
   }
-  stream << NLine(1);
 }
 
 void JavaCionGeneratorBase::GenShareFile(std::ofstream& stream,
index d9cb032c7431efb277cdf4e9b7f9bbf1141645fc..59dba9e88ae845bb2e44515dab7e83a5bf8ba871 100644 (file)
 
 const char DEFAULT_PROXY_REPO[] =
 R"__java_cb(
-
 import android.content.Context;
-import androidx.lifecycle.MutableLiveData;
 
 import org.tizen.cion.*;
 
 import java.net.SocketTimeoutException;
-import java.util.ArrayList;
 
+/**
+ * Abstract class for making a client
+ */
 public abstract class ClientBase implements DiscoveryCallback,
         ClientConnectionLifecycleCallback, PayloadAsyncResultCallback {
-    private ClientChannel client;
-    private Context context;
-
-    public ClientBase(Context context, String serviceName) {
-        client = new ClientChannel(context, serviceName);
-        this.context = context;
-    }
-
-    public ClientBase(Context context, String serviceName, SecurityInfo sec) {
-        client = new ClientChannel(context, serviceName, sec);
-        this.context = context;
-    }
-
+    private ClientChannel mClient;
+
+    private Context mContext;
+
+    /**
+     * Constructor
+     * @param mContext The Context
+     * @param serviceName Service name
+     */
+    public ClientBase(Context mContext, String serviceName) {
+        mClient = new ClientChannel(mContext, serviceName);
+        this.mContext = mContext;
+    }
+
+    /**
+     * Constructor with security information
+     * @param mContext The context
+     * @param serviceName Service name
+     * @param sec Security information
+     */
+    public ClientBase(Context mContext, String serviceName, SecurityInfo sec) {
+        mClient = new ClientChannel(mContext, serviceName, sec);
+        this.mContext = mContext;
+    }
+
+    /**
+     * Disconnects server
+     */
     public void disconnect() {
-        client.disconnect();
+        mClient.disconnect();
     }
 
+    /**
+     * Connects the server
+     * @param peer Server information
+     */
     public void tryConnect(PeerInfo peer) {
-        client.tryConnect(peer, this);
+        mClient.tryConnect(peer, this);
     }
 
+    /**
+     * Finds available servers
+     */
     public void tryDiscovery() {
-        client.tryDiscovery(this);
+        mClient.tryDiscovery(this);
+    }
+
+    /**
+     * Stops finding servers
+     */
+    public void stopDiscovery() {
+        mClient.stopDiscovery();
     }
 
+    /**
+     * Sends data payload asynchronously to the connected server
+     * @param payload Data payload
+     */
     public void sendAsync(DataPayload payload) {
-        client.sendPayloadAsync(payload, this);
+        mClient.sendPayloadAsync(payload, this);
     }
 
+    /**
+     * Sends file payload asynchronously to the connected server
+     * @param payload File payload
+     */
     public void sendAsync(FilePayload payload) {
-        client.sendPayloadAsync(payload, this);
+        mClient.sendPayloadAsync(payload, this);
     }
 
+    /**
+     * Sends data synchronously to the connected server
+     * @param data Data to send
+     * @return Received data
+     */
     public byte[] sendData(byte[] data) {
         try {
-            return client.sendData(data, 5000);
+            return mClient.sendData(data, 5000);
         } catch (SocketTimeoutException e) {
             e.printStackTrace();
         }
         return null;
     }
+
+    @Override
+    public final void onLost(PeerInfo peerInfo) {
+    }
 }
 
 )__java_cb";
@@ -80,64 +126,109 @@ const char DEFAULT_STUB_REPO[] =
 R"__java_cb(
 import android.content.Context;
 
-import androidx.lifecycle.LiveData;
-import androidx.lifecycle.MutableLiveData;
-
 import org.tizen.cion.*;
 
-import java.util.ArrayList;
-import java.util.concurrent.BlockingDeque;
-import java.util.concurrent.TimeUnit;
-
-public abstract class ServerBase implements ServerConnectionLifecycleCallback {
-    private ServerChannel server;
-    private Context context;
-    private String serviceName;
-    private String displayName;
-
-    public ServerBase(Context context, String serviceName, String displayName) {
-        server = new ServerChannel(context, serviceName, displayName);
-        this.context = context;
-        this.serviceName = serviceName;
-        this.displayName = displayName;
-    }
-
-    public ServerBase(Context context, String serviceName, String displayName, SecurityInfo sec) {
-        server = new ServerChannel(context, serviceName, displayName, sec);
-        this.context = context;
-        this.serviceName = serviceName;
-        this.displayName = displayName;
-    }
-
+/**
+ * Abstract class for making a server
+ */
+public abstract class ServerBase implements ServerConnectionLifecycleCallback,
+        PayloadAsyncResultCallback {
+    private ServerChannel mServer;
+
+    private Context mContext;
+
+    private String mServiceName;
+
+    private String mDisplayName;
+
+    /**
+     * Constructor
+     * @param mContext Context
+     * @param mServiceName Service name
+     * @param mDisplayName Display name
+     */
+    public ServerBase(Context mContext, String mServiceName, String mDisplayName) {
+        mServer = new ServerChannel(mContext, mServiceName, mDisplayName);
+        this.mContext = mContext;
+        this.mServiceName = mServiceName;
+        this.mDisplayName = mDisplayName;
+    }
+
+    /**
+     * Constructor with security information
+     * @param mContext Context
+     * @param mServiceName Service name
+     * @param mDisplayName Display name
+     * @param sec Security information
+     */
+    public ServerBase(Context mContext, String mServiceName, String mDisplayName, SecurityInfo sec) {
+        mServer = new ServerChannel(mContext, mServiceName, mDisplayName, sec);
+        this.mContext = mContext;
+        this.mServiceName = mServiceName;
+        this.mDisplayName = mDisplayName;
+    }
+
+    /**
+     * Gets service name
+     * @return Service name
+     */
     public String getServiceName() {
-      return serviceName;
+      return mServiceName;
     }
 
+    /**
+     * Gets display name
+     * @return Display name
+     */
     public String getDisplayName() {
-      return displayName;
+      return mDisplayName;
     }
 
+    /**
+     * Waits clients
+     */
     public void listen() {
-        server.listen(this);
+        mServer.listen(this);
     }
 
+    /**
+     * Stops waiting clients
+     */
     public void stop() {
-        server.stop();
+        mServer.stop();
     }
 
+    /**
+     * Disconnects the connected client
+     * @param peerInfo Client information
+     */
     public void disconnect(PeerInfo peerInfo) {
-        server.disconnect(peerInfo);
-    }
-
-    public void sendPayloadAsync(IPayload payload) {
+        mServer.disconnect(peerInfo);
     }
 
+    /**
+     * Accepts the client
+     * @param peerInfo Client information
+     */
     public void accept(PeerInfo peerInfo) {
-        server.acceptRequest(peerInfo);
+        mServer.acceptRequest(peerInfo);
     }
 
+    /**
+     * Rejects the client
+     * @param peerInfo Client information
+     * @param reason The reason for rejecting the client
+     */
     public void reject(PeerInfo peerInfo, String reason) {
-        server.rejectRequest(peerInfo, reason);
+        mServer.rejectRequest(peerInfo, reason);
+    }
+
+    /**
+     * Sends data asynchronously to the all connected clients
+     * @param payload Data
+     */
+    public void sendPayloadAsync(IPayload payload) {
+        mServer.sendPayloadAsync(payload, this);
     }
 }
 
@@ -188,46 +279,79 @@ R"__java_cb(
 
 import org.tizen.cion.CionParcel;
 
+/**
+ * Abstract class for making delegator
+ */
 public abstract class DelegatorBase {
-    private int id;
-    private int seqId;
-    private boolean once;
-    private static int _seqNum = 0;
+    private int mId;
+
+    private int mSeqId;
+
+    private boolean mOnce;
+
+    private static int sSeqNum = 0;
+
 <DELEGATOR_IDS>
 
+    /**
+     * Constructor
+     * @param delegateId Delegate ID
+     * @param once Use only once
+     */
     public DelegatorBase(int delegateId, boolean once) {
-        this.id = delegateId;
-        this.seqId = _seqNum++;
-        this.once = once;
+        this.mId = delegateId;
+        this.mSeqId = sSeqNum++;
+        this.mOnce = once;
     }
+
+    /**
+     * This method will be invoked when the remote callback is called
+     * @param parcel Data
+     */
     public abstract void onInvoked(CionParcel parcel);
 
+    /**
+     * Gets sequence ID
+     * @return Sequence ID
+     */
     public int getDelegateId() {
-      return id;
+      return mId;
     }
 
+    /**
+     * Gets sequence ID
+     * @return Sequence ID
+     */
     public int getSequenceId() {
-      return seqId;
+      return mSeqId;
     }
 
+    /**
+     * Gets once flag
+     * @return Once flag
+     */
     public boolean isOnce() {
-        return once;
+        return mOnce;
     }
 
     public static void serialize(CionParcel h, DelegatorBase from) {
-        h.write(from.id);
-        h.write(from.seqId);
-        h.write(from.once);
+        h.write(from.mId);
+        h.write(from.mSeqId);
+        h.write(from.mOnce);
     }
 
     public static void deserialize(CionParcel h, DelegatorBase to) {
-        to.id = h.readInt();
-        to.seqId = h.readInt();
-        to.once = h.readBoolean();
+        to.mId = h.readInt();
+        to.mSeqId = h.readInt();
+        to.mOnce = h.readBoolean();
     }
 
+    /**
+     * Gets once flag
+     * @return Once flag
+     */
     public String getTag() {
-        return (new Integer(id).toString()) + "_" + (new Integer(seqId).toString());
+        return (new Integer(mId).toString()) + "_" + (new Integer(mSeqId).toString());
     }
 }
 
@@ -235,21 +359,30 @@ public abstract class DelegatorBase {
 
 const char CB_CALLBACK_CLASS_PROXY[] =
 R"__java_cb(
-    public static final class <CLS_NAME> extends DelegatorBase {
+    public static class <CLS_NAME> extends DelegatorBase {
 
+        /**
+         * Constructor
+        */
         public <CLS_NAME>(boolean once) {
             super(DelegatorBase.<IFACE_NAME>_<DELEGATOR_NAME>__, once);
         }
 
+        /**
+         * Constructor
+        */
         public <CLS_NAME>() {
             super(DelegatorBase.<IFACE_NAME>_<DELEGATOR_NAME>__, false);
         }
 
         @Override
-        public void onInvoked(CionParcel parcel) {
+        public final void onInvoked(CionParcel parcel) {
 <METHOD_ON_INVOKED>
         }
 
+        /**
+         * This method will be invoked when remote callback is called
+         */
         public void onInvoked(<CALLBACK_PARAMS>) {}
     }
 )__java_cb";
@@ -257,25 +390,31 @@ R"__java_cb(
 const char CB_CALLBACK_CLASS_STUB[] =
 R"__java_cb(
     public static final class <CLS_NAME> extends DelegatorBase {
-        private PeerInfo peerInfo;
-        private WeakReference<ServiceBase> service;
-        private boolean valid = true;
-        private <IFACE_NAME> serverBase;
+        private PeerInfo mPeerInfo;
+
+        private WeakReference<ServiceBase> mService;
+
+        private boolean mValid = true;
+
+        private <IFACE_NAME> mServerBase;
 
         public <CLS_NAME>(PeerInfo info, WeakReference<ServiceBase> service) {
             super(DelegatorBase.<IFACE_NAME>_<DELEGATOR_NAME>__, false);
-            this.peerInfo = info;
-            this.service = service;
-            this.serverBase = (<IFACE_NAME>) service.get().serverBase;
+            this.mPeerInfo = info;
+            this.mService = service;
+            this.mServerBase = (<IFACE_NAME>) service.get().mServerBase;
         }
 
         @Override
-        public void onInvoked(CionParcel parcel) {}
+        public final void onInvoked(CionParcel parcel) {}
 
+        /**
+         * Invokes a remote callback
+         */
         public void Invoke(<CALLBACK_PARAMS>) {
-            if (service.get() == null)
+            if (mService.get() == null)
                 throw new InvalidProtocolException();
-            if (isOnce() && !valid)
+            if (isOnce() && !mValid)
                 throw new InvalidCallbackException();
 
             CionParcel p = new CionParcel();
@@ -285,8 +424,8 @@ R"__java_cb(
 <SERIALIZE>
             // Send
             DataPayload dp = new DataPayload(p.toByteArray());
-            serverBase.sendPayloadAsync(dp);
-            valid = false;
+            mServerBase.sendPayloadAsync(dp);
+            mValid = false;
 <SHARE_FILE>
         }
     }
index 19029c40bb5916e9ccdeb9559dae439f83851171..adc9529b894b0acbba65b57465c608cc67fe61be 100644 (file)
@@ -153,15 +153,15 @@ void JavaCionProxyGen::GenInvocation(std::ofstream& stream, const Declaration& d
           id += ".get()";
         m += ConvertTypeToSerializer(pt.GetBaseType(), id, "p");
         if (IsDelegateType(pt.GetBaseType())) {
-          l += "_delegateList.add(" + id + ");\n";
+          l += "mDelegateList.add(" + id + ");\n";
         }
       }
 
       st += AddIndent(TAB_SIZE * 2, m) + NLine(1);
 
-      st += Tab(2) + "synchronized (_lock) {" + NLine(1);
+      st += Tab(2) + "synchronized (mLock) {" + NLine(1);
       if (!l.empty())
-        st += AddIndent(TAB_SIZE * 2, l) + NLine(1);
+        st += AddIndent(TAB_SIZE * 3, l) + NLine(1);
 
       // Deserialize
       if (decl.GetMethodType() == Declaration::MethodType::ASYNC) {
@@ -205,15 +205,15 @@ void JavaCionProxyGen::GenInvocation(std::ofstream& stream, const Declaration& d
         c += i->GetID() + ".set(" + i->GetID() + "_raw);" + NLine(1);
 
         if (c != "")
-          st += AddIndent(TAB_SIZE * 2, c);
+          st += AddIndent(TAB_SIZE * 3, c);
       }
 
       if (decl.GetType().ToString() != "void") {
-        st += AddIndent(TAB_SIZE * 2, ConvertTypeToDeserializer(decl.GetType(),
+        st += AddIndent(TAB_SIZE * 3, ConvertTypeToDeserializer(decl.GetType(),
             "ret", "parcelReceived"));
       }
 
-      st += NLine(1) + Tab(2) + "return ret;" + NLine(1);
+      st += NLine(1) + Tab(3) + "return ret;" + NLine(1);
       st += Tab(2) + "}";
 
       return st;
index d9ef4d2b35965142114c275a243790022ad31f95..628b150958c80b12de3a633a73fac9b63e1aef67 100644 (file)
 const char CB_DATA_MEMBERS[] =
 R"__java_cb(
     public String serviceName;
-    private static final String _tidlVersion = "<VERSION>";
-    private boolean _online = false;
-    private Object _lock = new Object();
-    private List<DelegatorBase> _delegateList = new LinkedList<DelegatorBase>();
+
+    private static final String sTidlVersion = "<VERSION>";
+
+    private boolean mOnline = false;
+
+    private Object mLock = new Object();
+
+    private List<DelegatorBase> mDelegateList = new LinkedList<DelegatorBase>();
 )__java_cb";
 
 const char CB_EVENT_METHODS[] =
@@ -34,42 +38,51 @@ R"__java_cb(
         int seqId = parcel.readInt();
         boolean once = parcel.readBoolean();
 
-        for (DelegatorBase i : _delegateList) {
+        for (DelegatorBase i : mDelegateList) {
             if (i.getDelegateId() == id && i.getSequenceId() == seqId) {
                 i.onInvoked(parcel);
                 if (i.isOnce())
-                    _delegateList.remove(i);
+                    mDelegateList.remove(i);
                 break;
             }
         }
     }
 
+    /**
+     * This method will be invoked when this client gets the response from the server
+     * @param peerInfo Server information
+     * @param result Connection result
+     */
     @Override
     public void onConnectionResult(PeerInfo peerInfo, ConnectionResult result) {
         if (result.status == ConnectionResult.ConnectionStatus.CONNECTION_OK) {
-            _online = true;
+            mOnline = true;
         }
     }
 
+    /**
+     * This method will be invoked when this client is disconnected from the server
+     * @param peerInfo Server information
+     */
     @Override
     public void onDisconnected(PeerInfo peerInfo) {
-        _online = false;
+        mOnline = false;
     }
 
+    /**
+     * This method will be invoked when an available server is discovered
+     * @param peerInfo Server information
+     */
     @Override
     public void onDiscovered(PeerInfo peerInfo) {
     }
 
     @Override
-    public void onLost(PeerInfo peerInfo) {
-    }
-
-    @Override
-    public void onResultReceived(PayloadAsyncResult payloadAsyncResult) {
+    public final void onResultReceived(PayloadAsyncResult payloadAsyncResult) {
     }
 
     @Override
-    public void onPayloadReceived(IPayload payload, PayloadTransferStatus status) {
+    public final void onPayloadReceived(IPayload payload, PayloadTransferStatus status) {
         if(payload.getType() == IPayload.PayloadType.PAYLOAD_FILE) {
             onFileReceived((FilePayload)payload, status);
         } else {
@@ -84,52 +97,25 @@ R"__java_cb(
         }
     }
 
+    /**
+     * This method will be invoked when data for a file is received from the server
+     * @param payload File data
+     * @param status Status
+     */
     public void onFileReceived(FilePayload payload, PayloadTransferStatus status) {}
 
 )__java_cb";
 
 const char CB_CONNECT_METHOD[] =
 R"__java_cb(
-    /// <summary>
-    /// Starts discovering cion servers.
-    /// </summary>
-    /// <exception cref="InvalidOperationException">Thrown when the discovery operation is already in progress.</exception>
-    @Override
-    public void tryDiscovery() {
-        super.tryDiscovery();
-    }
-
-    /// <summary>
-    /// Connects to the stub app.
-    /// </summary>
-    /// <param name="peer">The peer to connect.</param>
-    /// <privilege>http://tizen.org/privilege/d2d.datasharing</privilege>
-    /// <privilege>http://tizen.org/privilege/internet</privilege>
-    /// <exception cref="PermissionDeniedException">
-    /// Thrown when the permission is denied.
-    /// </exception>
-    /// <remark> If you want to use this method, you must add privileges.</remark>
-    @Override
-    public void tryConnect(PeerInfo peer) {
-        super.tryConnect(peer);
-    }
-
-    /// <summary>
-    /// Disconnects from the stub app.
-    /// </summary>
-    @Override
-    public void disconnect() {
-        super.disconnect();
-    }
-
-    /// <summary>
-    /// Disposes delegate objects in this interface
-    /// </summary>
-    /// <param name="tag">The tag string from delegate object</param>
+    /**
+     * Disposes delegate objects in this interface
+     * @param tag String handle
+     */
     public void disposeCallback(String tag) {
-        for (DelegatorBase i : _delegateList) {
+        for (DelegatorBase i : mDelegateList) {
             if (i.getTag().equals(tag)) {
-                _delegateList.remove(i);
+                mDelegateList.remove(i);
                 return;
             }
         }
@@ -137,7 +123,7 @@ R"__java_cb(
 )__java_cb";
 
 const char CB_INVOCATION_PRE[] =
-R"__java_cb(        if (!_online)
+R"__java_cb(        if (!mOnline)
             throw new NotConnectedSocketException();
 
         CionParcel p = new CionParcel();
@@ -146,28 +132,28 @@ $$
 
 const char CB_SHARE_FILE[] =
 R"__java_cb(
-        try {
+            try {
 $$
-        } catch (InvalidArgumentException e) {
-        }
+            } catch (InvalidArgumentException e) {
+            }
 )__java_cb";
 
 const char CB_ASYNC_INVOCATION_MID[] =
 R"__java_cb(
-        // Send
-        DataPayload dp = new DataPayload(p.toByteArray());
-        super.sendAsync(dp);
+            // Send
+            DataPayload dp = new DataPayload(p.toByteArray());
+            super.sendAsync(dp);
 )__java_cb";
 
 const char CB_SYNC_INVOCATION_MID[] =
 R"__java_cb(
-        // Send
-        byte[] dataReceived = sendData(p.toByteArray());
+            // Send
+            byte[] dataReceived = sendData(p.toByteArray());
 
-        CionParcel parcelReceived = new CionParcel(dataReceived);
+            CionParcel parcelReceived = new CionParcel(dataReceived);
 
-        int cmd = parcelReceived.readInt();
-        if (cmd != __RESULT)
-            throw new InvalidProtocolException();
+            int cmd = parcelReceived.readInt();
+            if (cmd != __RESULT)
+                throw new InvalidProtocolException();
 )__java_cb";
 #endif  // IDLC_JAVA_CION_GEN_JAVA_PROXY_GEN_CB_H_
index 439470d6f25e58bd9e33c4c594fec63f86b9404d..a61f3f9b6b7a86971e2523cff73dbaa634852193 100644 (file)
@@ -56,19 +56,11 @@ void JavaCionStructureGen::GenStructure(std::ofstream& stream,
   stream << NLine(1);
   stream << "public final class " << st.GetID() << " ";
   GenBrace(stream, 0, [&]() {
-    stream << NLine(1);
-    for (auto& i : st.GetElements().GetElms()) {
-      GenSetter(stream, *i);
-      GenGetter(stream, *i);
-      stream << NLine(1);
-    }
-
-    stream << NLine(1);
     GenTemplate(variable, stream,
       [&]()->std::string {
         std::string str;
         for (auto& i : st.GetElements().GetElms()) {
-          str += NLine(1) + Tab(1);
+          str += NLine(1) + Tab(1) + "private ";
           if (i->GetType().GetMetaType() == nullptr) {
             str += ConvertTypeToString(i->GetType()) + " "
                 + i->GetID() + "_;";
@@ -77,10 +69,17 @@ void JavaCionStructureGen::GenStructure(std::ofstream& stream,
                 + i->GetID() + "_ = new "
                 + ConvertTypeToString(i->GetType()) + "();";
           }
+          str += NLine(1);
         }
-        str += NLine(1);
+
         return str;
       });
+
+    for (auto& i : st.GetElements().GetElms()) {
+      GenSetter(stream, *i);
+      GenGetter(stream, *i);
+      stream << NLine(1);
+    }
   }, false, false);
   stream << NLine(1);
 }
index e7bed248fc2297e112f3001b8959dc56ef7783ae..1e3eeb19921f7b65c1e844b93f15a75291afeb3e 100644 (file)
 #define IDLC_JAVA_CION_GEN_JAVA_STUB_GEN_CB_H_
 
 const char CB_DATA_MEMBERS[] =
-R"__java_cb(    private List<ServiceBase> _services = new LinkedList<ServiceBase>();
-    private Class<?> _serviceType;
-    private static final String _tidlVersion = "<VERSION>";
+R"__java_cb(    private List<ServiceBase> mServices = new LinkedList<ServiceBase>();
+
+    private Class<?> mServiceType;
+
+    private static final String sTidlVersion = "<VERSION>";
+
 )__java_cb";
 
 const char CB_SERVICE_BASE_FRONT[] =
 R"__java_cb(
+    /**
+     * Abstract class for making a service
+     */
     public abstract class ServiceBase {
-        String serviceName;
-        String displayName;
-        PeerInfo client;
-        PeerInfo connectionRequestClient;
-        ServerBase serverBase;
-
-        /// <summary>
-        /// The name of service
-        /// </summary>
-        public String getServiceName() {
-            return serviceName;
+        private String mServiceName;
+
+        private String mDisplayName;
+
+        private PeerInfo mClient;
+
+        private PeerInfo mConnectionRequestClient;
+
+        private ServerBase mServerBase;
+
+        /**
+         * Gets service name
+         * @return Service name
+         */
+        public String getmServiceName() {
+            return mServiceName;
         }
 
-        /// <summary>
-        /// The display name of service
-        /// </summary>
-        public String getDisplayName() {
-              return displayName;
+        /**
+         * Gets display name
+         * @return Display name
+         */
+        public String getmDisplayName() {
+              return mDisplayName;
         }
 
-        /// <summary>
-        /// The PeerInfo of client
-        /// </summary>
-        public PeerInfo getClient() {
-            return client;
+        /**
+         * Gets client information
+         * @return Client information
+         */
+        public PeerInfo getmClient() {
+            return mClient;
         }
 
         protected ServiceBase() {}
 
-        /// <summary>
-        /// Disconnects from the client app
-        /// </summary>
-        /// <exception cref="System.InvalidOperationException">
-        /// Thrown when an internal IO error occurrs.
-        /// </exception>
+        /**
+         * Disconnects from the client app
+         */
         public void disconnect() {
-            if (client != null)
-                serverBase.disconnect(client);
+            if (mClient != null)
+                mServerBase.disconnect(mClient);
         }
 
-        /// <summary>
-        /// Accepts the connection request from the client.
-        /// </summary>
+        /**
+         * Accepts the connection request from the client
+         */
         public void accept() {
-            if (connectionRequestClient != null)
-                serverBase.accept(connectionRequestClient);
+            if (mConnectionRequestClient != null)
+                mServerBase.accept(mConnectionRequestClient);
         }
 
-        /// <summary>
-        /// Rejects the connection request from the client.
-        /// </summary>
-        /// <param name="reason">The reason why reject the connection request.</param>
+        /**
+         * Rejects the connection request from the client
+         * @param reason The season
+         */
         public void reject(String reason) {
-            if (connectionRequestClient != null)
-                serverBase.reject(connectionRequestClient, reason);
+            if (mConnectionRequestClient != null)
+                mServerBase.reject(mConnectionRequestClient, reason);
         }
 
-        /// <summary>
-        /// This method will be called when connection requested from the client
-        /// </summary>
+        /**
+         * This method will be called when connection requested from the client
+         */
         public abstract void onConnectionRequest();
 
-        /// <summary>
-        /// This method will be called when received file payload.
-        /// </summary>
+        /**
+         * This method will be called when received file payload
+         * @param file File information
+         * @param status The status
+         */
         public abstract void onFilePayloadReceived(FilePayload file, PayloadTransferStatus status);
 
-        /// <summary>
-        /// This method will be called when the client is disconnected
-        /// </summary>
+        /**
+         * This method will be called when the client is disconnected
+         */
         public abstract void onTerminate();
 
-        /// <summary>
-        /// This method will be called when the client is connected
-        /// </summary>
+        /**
+         * This method will be called when the client is connected
+         */
         public abstract void onConnected();
 
 )__java_cb";
@@ -108,17 +120,17 @@ R"__java_cb(
 const char CB_ON_RECEIVED_ASYNC_EVENT_FRONT[] =
 R"__java_cb(
     @Override
-    public void onPayloadReceived(PeerInfo info, IPayload data, PayloadTransferStatus status) {
+    public final void onPayloadReceived(PeerInfo info, IPayload data, PayloadTransferStatus status) {
         try {
             CionParcel p;
             ServiceBase b = null;
 
-            for (ServiceBase i : _services) {
-                if (i.client == null)
+            for (ServiceBase i : mServices) {
+                if (i.mClient == null)
                     continue;
 
-                if (i.client.getAppId().equals(info.getAppId()) &&
-                    i.client.getUuid().equals(info.getUuid())) {
+                if (i.mClient.getAppId().equals(info.getAppId()) &&
+                    i.mClient.getUuid().equals(info.getUuid())) {
                     b = i;
                     break;
                 }
@@ -152,7 +164,7 @@ R"__java_cb(
 const char CB_ON_RECEIVED_SYNC_EVENT_FRONT[] =
 R"__java_cb(
     @Override
-    public byte[] onDataReceived(PeerInfo info, byte[] data) {
+    public final byte[] onDataReceived(PeerInfo info, byte[] data) {
         CionParcel p;
         byte[] returnData = new byte[0];
 
@@ -160,12 +172,12 @@ R"__java_cb(
         try {
             ServiceBase b = null;
 
-            for (ServiceBase i : _services) {
-                if (i.client == null)
+            for (ServiceBase i : mServices) {
+                if (i.mClient == null)
                     continue;
 
-                if (i.client.getAppId().equals(info.getAppId()) &&
-                    i.client.getUuid().equals(info.getUuid())) {
+                if (i.mClient.getAppId().equals(info.getAppId()) &&
+                    i.mClient.getUuid().equals(info.getUuid())) {
                     b = i;
                     break;
                 }
@@ -200,18 +212,18 @@ R"__java_cb(
     public void onConnectionRequest(PeerInfo peerInfo) {
         ServiceBase s;
         try {
-            final Object o = _serviceType.newInstance();
+            final Object o = mServiceType.newInstance();
             s = (ServiceBase) o;
         } catch (Exception e) {
             return;
         }
 
-        s.serviceName = getServiceName();
-        s.displayName = getDisplayName();
-        s.connectionRequestClient = peerInfo;
-        s.serverBase = this;
+        s.mServiceName = getServiceName();
+        s.mDisplayName = getDisplayName();
+        s.mConnectionRequestClient = peerInfo;
+        s.mServerBase = this;
         s.onConnectionRequest();
-        _services.add(s);
+        mServices.add(s);
     }
 )__java_cb";
 
@@ -219,18 +231,18 @@ const char CB_ON_CONNECTED_EVENT[] =
 R"__java_cb(
     @Override
     public void onConnectionResult(PeerInfo peerInfo, ConnectionResult result) {
-        for (ServiceBase i : _services) {
-            if (i.connectionRequestClient == null)
+        for (ServiceBase i : mServices) {
+            if (i.mConnectionRequestClient == null)
                 continue;
 
-            if (i.connectionRequestClient.getAppId().equals(peerInfo.getAppId()) &&
-                i.connectionRequestClient.getUuid().equals(peerInfo.getUuid())) {
+            if (i.mConnectionRequestClient.getAppId().equals(peerInfo.getAppId()) &&
+                i.mConnectionRequestClient.getUuid().equals(peerInfo.getUuid())) {
                 if (result.status == ConnectionResult.ConnectionStatus.CONNECTION_OK) {
-                    i.client = i.connectionRequestClient;
-                    i.connectionRequestClient = null;
+                    i.mClient = i.mConnectionRequestClient;
+                    i.mConnectionRequestClient = null;
                     i.onConnected();
                 } else {
-                    _services.remove(i);
+                    mServices.remove(i);
                 }
                 break;
             }
@@ -243,14 +255,14 @@ const char CB_ON_DISCONNECTED_EVENT[] =
 R"__java_cb(
     @Override
     public void onDisconnected(PeerInfo peerInfo) {
-        for (ServiceBase i : _services) {
-            if (i.client == null)
+        for (ServiceBase i : mServices) {
+            if (i.mClient == null)
                 continue;
 
-            if (i.client.getAppId().equals(peerInfo.getAppId()) &&
-                i.client.getUuid().equals(peerInfo.getUuid())) {
+            if (i.mClient.getAppId().equals(peerInfo.getAppId()) &&
+                i.mClient.getUuid().equals(peerInfo.getUuid())) {
                 i.onTerminate();
-                _services.remove(i);
+                mServices.remove(i);
                 break;
             }
         }
@@ -259,45 +271,36 @@ R"__java_cb(
 
 const char CB_COMMON_METHODS[] =
 R"__java_cb(
-    /// <summary>
-    /// Listens to client apps
-    /// </summary>
-    /// <param name="serviceType">The type object for making service instances</param>
-    /// <exception cref="InvalidIOException">
-    /// Thrown when internal I/O error happen.
-    /// </exception>
-    /// <exception cref="ArgumentException">
-    /// Thrown when serviceType is invalid.
-    /// </exception>
-    /// <exception cref="InvalidOperationException">
-    /// Thrown when the listen operation is already in progress.
-    /// </exception>
-    /// <exception cref="UnauthorizedAccessException">
-    /// Thrown when an application does not have the privilege to access this method.
-    /// </exception>
-    /// <privilege>http://tizen.org/privilege/d2d.datasharing</privilege>
-    /// <privilege>http://tizen.org/privilege/internet</privilege>
+    @Override
+    public final void onResultReceived(PayloadAsyncResult payloadAsyncResult) {
+    }
+
+    /**
+     * Waits clients
+     * @param serviceType Service class type
+     */
     public void listen(Class<?> serviceType) {
-        _serviceType = serviceType;
+        mServiceType = serviceType;
         super.listen();
     }
 
-    /// <summary>
-    /// Stops the listen operation.
-    /// </summary>
-    /// <exception cref="InvalidOperationException">Thrown when the server is not listening.</exception>
+    /**
+     * Stops the listen operation
+     */
+    @Override
     public void stop() {
         super.stop();
-        _services.clear();
+        mServices.clear();
     }
 
-    /// <summary>
-    /// Gets service objects which are connected
-    /// </summary>
-    /// <returns>The enumerable service objects which are connected</returns>
+    /**
+     * Gets service objects which are connected
+     * @return Service objects which are connected
+     */
     public List<ServiceBase> getServices() {
-        return _services;
+        return mServices;
     }
+
 )__java_cb";