1 //******************************************************************
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 package org.iotivity.service.ns.consumer;
23 import android.util.Log;
24 import org.iotivity.service.ns.common.*;
25 import java.util.Vector;
29 * @brief This class provides implementation of Notification Provider object.
33 private static final String LOG_TAG = "ConsumerService_Provider";
35 public enum ProviderState
43 private ProviderState(int state)
48 public int getProviderState()
54 public String mProviderId = null;
55 private long mNativeHandle = 0;
57 public Provider(String providerId)
59 Log.i (LOG_TAG, "Provider()");
61 mProviderId = providerId;
64 public String getProviderId()
69 public TopicsList getTopicList() throws NSException
71 return nativeGetTopicList();
74 public ProviderState getProviderState() throws NSException
76 return nativeGetProviderState();
79 public void subscribe() throws NSException
84 public boolean isSubscribed () throws NSException
86 return nativeIsSubscribed();
89 public void sendSyncInfo(long messageId, SyncInfo.SyncType syncType) throws NSException
91 nativeSendSyncInfo(messageId, syncType.ordinal());
94 public void setListener(OnProviderStateListener onProviderStateListener,
95 OnMessageReceivedListner onMessageReceivedListner,
96 OnSyncInfoReceivedListner onSyncInfoReceivedListner) throws NSException
98 nativeSetListener(onProviderStateListener, onMessageReceivedListner, onSyncInfoReceivedListner);
101 public int updateTopicList(TopicsList topicsList) throws NSException
103 return nativeUpdateTopicList(topicsList);
106 public interface OnProviderStateListener
108 public void onProviderStateReceived(ProviderState state);
111 public interface OnMessageReceivedListner
113 public void onMessageReceived(Message message);
116 public interface OnSyncInfoReceivedListner
118 public void onSyncInfoReceived(SyncInfo sync);
121 private native void nativeSubscribe() throws NSException;
122 private native void nativeSendSyncInfo(long messageId, int syncType) throws NSException;
123 private native void nativeSetListener(OnProviderStateListener onProviderStateListener,
124 OnMessageReceivedListner onMessageReceivedListner,
125 OnSyncInfoReceivedListner onSyncInfoReceivedListner) throws NSException;
126 public native TopicsList nativeGetTopicList() throws NSException;
127 private native int nativeUpdateTopicList(TopicsList topicsList) throws NSException;
128 private native ProviderState nativeGetProviderState() throws NSException;
129 public native boolean nativeIsSubscribed() throws NSException;