1 //******************************************************************
\r
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
\r
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
7 // Licensed under the Apache License, Version 2.0 (the "License");
\r
8 // you may not use this file except in compliance with the License.
\r
9 // You may obtain a copy of the License at
\r
11 // http://www.apache.org/licenses/LICENSE-2.0
\r
13 // Unless required by applicable law or agreed to in writing, software
\r
14 // distributed under the License is distributed on an "AS IS" BASIS,
\r
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 // See the License for the specific language governing permissions and
\r
17 // limitations under the License.
\r
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
20 #include "NSProviderSystem.h"
\r
22 #define MAX_SERVER_ADDRESS 32
\r
23 static NSConnectionState NSProviderConnectionState;
\r
24 static char NSRemoteServerAddress[MAX_SERVER_ADDRESS] = {0,};
\r
26 NSProviderInfo * providerInfo;
\r
28 void NSSetProviderConnectionState(NSConnectionState state)
\r
30 NS_LOG(DEBUG, "NSSetProviderConnectionState");
\r
32 NSProviderConnectionState = state;
\r
35 NSConnectionState NSGetProviderConnectionState()
\r
37 NS_LOG(DEBUG, "Change Connection State");
\r
39 return NSProviderConnectionState;
\r
42 void NSSetRemoteServerAddress(char *serverAddress)
\r
45 OICStrcpy(NSRemoteServerAddress, MAX_SERVER_ADDRESS, serverAddress);
\r
48 void NSDeleteRemoteServerAddress(char *serverAddress)
\r
50 NS_LOG_V(DEBUG, "Delete cloud address: %s", serverAddress);
\r
52 memset(NSRemoteServerAddress, 0, MAX_SERVER_ADDRESS);
\r
55 bool NSIsRemoteServerAddress(char *serverAddress)
\r
57 NS_LOG_V(DEBUG, "Check server address: %s", serverAddress);
\r
59 if(serverAddress != NULL)
\r
61 return strstr(NSRemoteServerAddress, serverAddress);
\r
67 void NSInitProviderInfo()
\r
69 NS_LOG(DEBUG, "NSInitProviderInfo");
\r
71 providerInfo = (NSProviderInfo *) OICMalloc(sizeof(NSProviderInfo));
\r
72 const char * generatedUuid = (char *)OCGetServerInstanceIDString();
\r
73 NS_LOG_V(DEBUG, "Generate Provider ID: %s", generatedUuid);
\r
74 OICStrcpy(providerInfo->providerId, UUID_STRING_SIZE, generatedUuid);
\r
76 providerInfo->providerName = NULL;
\r
79 void NSDeinitProviderInfo()
\r
81 NS_LOG(DEBUG, "NSDeinitProviderInfo");
\r
83 if(providerInfo == NULL)
\r
85 NS_LOG(DEBUG, "providerInfo is NULL");
\r
89 if(providerInfo->providerName != NULL)
\r
91 OICFree(providerInfo->providerName);
\r
92 providerInfo->providerName = NULL;
\r
95 OICFree(providerInfo);
\r
96 providerInfo = NULL;
\r
99 NSProviderInfo * NSGetProviderInfo()
\r
101 NS_LOG_V(DEBUG, "ProviderInfo: %s", providerInfo->providerId);
\r
103 return providerInfo;
\r