428b02270295b4d7b0073fcf9a816b6d3b9177ff
[platform/upstream/iotivity.git] / service / notification / android / notification-service / src / main / java / org / iotivity / service / ns / provider / ProviderService.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 package org.iotivity.service.ns.provider;
21 import org.iotivity.service.ns.common.*;
22 import java.util.Vector;
23 /**
24   * @class   ProviderService
25   * @brief   This class provides a set of Java APIs for Notification ProviderService.
26   */
27 public class ProviderService
28 {
29
30     static
31     {
32         System.loadLibrary("gnustl_shared");
33         System.loadLibrary("oc_logger");
34         System.loadLibrary("connectivity_abstraction");
35         System.loadLibrary("ca-interface");
36         System.loadLibrary("octbstack");
37         System.loadLibrary("oc");
38         System.loadLibrary("ocstack-jni");
39         System.loadLibrary("notification_provider");
40         System.loadLibrary("notification_provider_wrapper");
41         System.loadLibrary("notification_provider_jni");
42     }
43
44     private static ProviderService instance;
45
46     static
47     {
48         instance = new ProviderService();
49     }
50
51     public static ProviderService getInstance()
52     {
53         return instance;
54     }
55
56     public int start(OnConsumerSubscribedListener  subscribedListener,
57                      OnMessageSynchronizedListener  messageSynchronized,
58                      boolean subControllability, String userInfo) throws NSException
59     {
60         return nativeStart(subscribedListener, messageSynchronized,subControllability,userInfo);
61     }
62
63     public int stop() throws NSException
64     {
65         return nativeStop();
66     }
67
68     public int   sendMessage(Message message) throws NSException
69     {
70         return nativeSendMessage(message);
71     }
72
73     public void sendSyncInfo ( long messageId , SyncInfo.SyncType syncType) throws NSException
74     {
75         nativeSendSyncInfo(messageId, syncType.ordinal());
76     }
77
78     public Message createMessage () throws NSException
79     {
80         return nativeCreateMessage();
81     }
82
83     public int   enableRemoteService(String servAdd) throws NSException
84     {
85         return nativeEnableRemoteService(servAdd);
86     }
87
88     public int  disableRemoteService(String servAdd) throws NSException
89     {
90         return nativeDisableRemoteService(servAdd);
91     }
92
93     public int registerTopic(String topicName) throws NSException
94     {
95         return nativeRegisterTopic(topicName);
96     }
97
98     public int unregisterTopic(String topicName) throws NSException
99     {
100         return nativeUnregisterTopic(topicName);
101     }
102
103     public TopicsList getRegisteredTopicList() throws NSException
104     {
105         return nativeGetRegisteredTopicList();
106     }
107
108     public interface OnConsumerSubscribedListener
109     {
110         public void onConsumerSubscribed(Consumer consumer);
111     }
112
113     public interface OnMessageSynchronizedListener
114     {
115         public void onMessageSynchronized(SyncInfo syncInfo);
116     }
117
118     public native int  nativeStart(OnConsumerSubscribedListener    subscribedListener,
119                                                  OnMessageSynchronizedListener   messageSynchronized,
120                                                  boolean subControllability, String userInfo) throws NSException;
121     public native int  nativeStop() throws NSException;
122     public native int  nativeSendMessage(Message message) throws NSException;
123     public native void  nativeSendSyncInfo( long messageId , int type) throws NSException;
124     public native Message nativeCreateMessage() throws NSException;
125     public native int  nativeEnableRemoteService(String servAdd) throws NSException;
126     public native int  nativeDisableRemoteService(String servAdd) throws NSException;
127     public native int  nativeRegisterTopic(String topicName) throws NSException;
128     public native int  nativeUnregisterTopic(String topicName) throws NSException;
129     public native TopicsList  nativeGetRegisteredTopicList() throws NSException;
130 }