Add doxygen comment for java api's of ProviderServicer and ConsumerService.
[platform/upstream/iotivity.git] / service / notification / android / notification-service / src / main / java / org / iotivity / service / ns / consumer / ConsumerService.java
1 //******************************************************************
2 //
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 package org.iotivity.service.ns.consumer;
22
23 import android.util.Log;
24 import org.iotivity.service.ns.common.*;
25 import java.util.Vector;
26
27 /**
28   * @class   ConsumerService
29   * @brief   This class provides a set of Java APIs for Notification Consumer.
30   */
31 public class ConsumerService
32 {
33     private static final String LOG_TAG = "ConsumerService";
34
35     static
36     {
37         System.loadLibrary("gnustl_shared");
38         System.loadLibrary("oc_logger");
39         System.loadLibrary("connectivity_abstraction");
40         System.loadLibrary("ca-interface");
41         System.loadLibrary("octbstack");
42         System.loadLibrary("oc");
43         System.loadLibrary("ocstack-jni");
44         System.loadLibrary("notification_consumer");
45         System.loadLibrary("notification_consumer_wrapper");
46         System.loadLibrary("notification_consumer_jni");
47     }
48
49     private static ConsumerService instance;
50     static
51     {
52         instance = new ConsumerService();
53     }
54
55     /**
56       * API for getting instance of ConsumerService
57       * @return ConsumerService singleton instance created
58       */
59     public static ConsumerService getInstance()
60     {
61         return instance;
62     }
63
64    /**
65      * Start ConsumerService
66      * @param onProviderDiscoveredListener - OnProviderDiscoveredListener Callback Interface
67      */
68     public void start(
69         OnProviderDiscoveredListener onProviderDiscoveredListener
70     ) throws NSException
71     {
72         nativeStart(onProviderDiscoveredListener);
73     }
74
75     /**
76       * Stop ConsumerService
77       */
78     public void stop() throws NSException
79     {
80         nativeStop();
81     }
82
83     /**
84       * Request to publish resource to cloud server
85       * @param[in]  serverAddress combined with IP address and port number using delimiter :
86       * @return  result code
87       */
88     public void enableRemoteService(String serverAddress) throws NSException
89     {
90         nativeEnableRemoteService(serverAddress);
91     }
92
93     /**
94       * Request discovery manually
95       */
96     public void rescanProvider() throws NSException
97     {
98         nativeRescanProvider();
99     }
100
101     /**
102       * Interface to implement callback function to receive provider on discovery
103       */
104     public interface OnProviderDiscoveredListener
105     {
106         /**
107           * Callback function to receive provider on discovery
108           * @param provider - Provider object
109           */
110         public void onProviderDiscovered(Provider provider);
111     }
112
113     private native void nativeStart (
114         OnProviderDiscoveredListener onProviderDiscoveredListener
115     ) throws NSException;
116
117     private native void nativeStop() throws NSException;
118     private native void nativeEnableRemoteService(String serverAddress) throws NSException;
119     private native void nativeRescanProvider() throws NSException;
120 }