eb8f30a1ebae9b9fb5b3112d8d40bb376347d410
[platform/upstream/iotivity.git] /
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     public interface OnSubscriptionListener
51     {
52         public void onConsumerSubscribed(Consumer consumer);
53     }
54     public interface OnSyncInfoListener
55     {
56         public void onMessageSynchronized(SyncInfo syncInfo);
57     }
58
59     public static ProviderService getInstance()
60     {
61         return instance;
62     }
63     public int Start(boolean policy,
64                      OnSubscriptionListener  subscriptionListener,
65                      OnSyncInfoListener  syncInfoListener) throws NSException
66     {
67
68         return nativeStart(policy, subscriptionListener, syncInfoListener);
69     }
70
71     public int Stop() throws NSException
72     {
73         return nativeStop();
74     }
75
76     public int   SendMessage(Message message) throws NSException
77     {
78         return nativeSendMessage(message);
79     }
80
81     public void SendSyncInfo ( long messageId , SyncInfo.SyncType syncType) throws NSException
82     {
83         nativeSendSyncInfo(messageId, syncType.ordinal());
84         return;
85     }
86
87     public Message CreateMessage () throws NSException
88     {
89         return nativeCreateMessage();
90     }
91
92     public int   EnableRemoteService(String servAdd) throws NSException
93     {
94         return nativeEnableRemoteService(servAdd);
95     }
96
97     public int  DisableRemoteService(String servAdd) throws NSException
98     {
99         return nativeDisableRemoteService(servAdd);
100     }
101
102     public int AddTopic(String topicName) throws NSException
103     {
104         return nativeAddTopic(topicName);
105     }
106     public int DeleteTopic(String topicName) throws NSException
107     {
108         return nativeDeleteTopic(topicName);
109     }
110     public TopicsList GetTopics() throws NSException
111     {
112         return nativeGetTopics();
113     }
114
115     public native int  nativeStart(boolean policy,
116                                OnSubscriptionListener   subscriptionListener,
117                                OnSyncInfoListener   syncInfoListener);
118     public native int  nativeStop();
119     public native int  nativeSendMessage(Message message);
120     public native void  nativeSendSyncInfo( long messageId , int type);
121     public native Message nativeCreateMessage();
122     public native int  nativeEnableRemoteService(String servAdd);
123     public native int  nativeDisableRemoteService(String servAdd);
124     public native int  nativeAddTopic(String topicName);
125     public native int  nativeDeleteTopic(String topicName);
126     public native TopicsList  nativeGetTopics();
127 }