622a09b8d98fcc56e758881a6c79d1fcbccd99f5
[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
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   Provider
29   * @brief   This class provides implementation of Notification Provider object.
30   */
31 public class Provider
32 {
33     private static final String LOG_TAG = "ConsumerService_Provider";
34
35     public String mProviderId        = null;
36     TopicsList mTopicsList = new TopicsList();
37     private long mNativeHandle       = 0;
38
39     public Provider(String providerId)
40     {
41         Log.i (LOG_TAG, "Provider()");
42
43         mProviderId = providerId;
44     }
45
46     public String getProviderId()
47     {
48         return mProviderId ;
49     }
50
51     public TopicsList  getTopicsList()
52     {
53         return mTopicsList ;
54     }
55
56     public void Subscribe() throws NSException
57     {
58         nativeSubscribe();
59     }
60
61     public void Unsubscribe() throws NSException
62     {
63         nativeUnsubscribe();
64     }
65
66     public void SendSyncInfo(long messageId, SyncInfo.SyncType syncType) throws NSException
67     {
68         nativeSendSyncInfo(messageId, syncType.ordinal());
69     }
70
71     public void SetListener(OnMessageReceivedListner onMessageReceivedListner,
72                             OnSyncInfoReceivedListner onSyncInfoReceivedListner) throws NSException
73     {
74         nativeSetListener(onMessageReceivedListner, onSyncInfoReceivedListner);
75     }
76
77     public int SelectInterestTopics(TopicsList topicsList) throws NSException
78     {
79         return nativeSelectInterestTopics(topicsList);
80     }
81
82     public interface OnMessageReceivedListner
83     {
84         public void onMessageReceived(Message message);
85     }
86
87     public interface OnSyncInfoReceivedListner
88     {
89         public void onSyncInfoReceived(SyncInfo sync);
90     }
91
92     private native void nativeSubscribe() throws NSException;
93     private native void nativeUnsubscribe() throws NSException;
94     private native void nativeSendSyncInfo(long messageId, int syncType) throws NSException;
95     private native void nativeSetListener(
96         OnMessageReceivedListner onMessageReceivedListner,
97         OnSyncInfoReceivedListner onSyncInfoReceivedListner
98     ) throws NSException;
99     private native int nativeSelectInterestTopics(TopicsList topicsList) throws NSException;
100 }