Use path in persistent storage open callback.
authorTodd Malsbary <todd.malsbary@intel.com>
Mon, 11 Sep 2017 23:22:36 +0000 (16:22 -0700)
committerTodd Malsbary <todd.malsbary@intel.com>
Mon, 18 Sep 2017 17:18:55 +0000 (17:18 +0000)
Bug: https://jira.iotivity.org/browse/IOT-2196
Change-Id: Ia72de1fd70d5b7b665e56661e53c5b97c51c375e
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
bridging/common/pluginServer.cpp
bridging/plugins/hue_plugin/hue_resource.cpp
bridging/plugins/lifx_plugin/lifxResource.cpp
bridging/plugins/lyric_plugin/honeywellResource.cpp
bridging/plugins/nest_plugin/nestResource.cpp
bridging/plugins/stub_plugin/stub_plugin.cpp

index c1a67b3..2dfee8a 100644 (file)
@@ -102,21 +102,8 @@ MPMPluginCtx *g_plugin_context = NULL;
  * It contains Server's Identity and the PSK credentials
  * of other devices which the server trusts
  */
-static char CRED_FILE[] = "./oic_svr_db_server.json";
 extern MPMCommonPluginCtx *g_com_ctx;
 
-FILE *serverFOpen(const char *path, const char *mode)
-{
-    if (0 == strcmp(path, OC_SECURITY_DB_DAT_FILE_NAME))
-    {
-        return fopen(CRED_FILE, mode);
-    }
-    else
-    {
-        return fopen(path, mode);
-    }
-}
-
 std::unique_ptr<ConcurrentIotivityUtils> iotivityUtils = NULL;
 
 /**
index af7e823..ca7bcf0 100644 (file)
@@ -99,11 +99,10 @@ const uint BINARY_SWITCH_CALLBACK = 0;
 const uint BRIGHTNESS_CALLBACK = 1;
 const uint CHROMA_CALLBACK = 2;
 
-const static char CRED_FILE[] = "./oic_svr_db_hue.dat";
-
-FILE *hue_fopen(const char * , const char *mode)
+FILE *hue_fopen(const char *path, const char *mode)
 {
-    return fopen(CRED_FILE, mode);
+    std::string filename = std::string("hue_") + path;
+    return fopen(filename.c_str(), mode);
 }
 
 MPMResult pluginCreate(MPMPluginCtx **pluginSpecificCtx)
index 7361fd3..8a33916 100644 (file)
@@ -57,7 +57,6 @@ static const std::string BINARY_SWITCH_RELATIVE_URI = "/switch";
 static const std::string BRIGHTNESS_RELATIVE_URI = "/brightness";
 
 std::string accessToken;
-const static char CRED_FILE[] = "./oic_svr_db_lifx.dat";
 
 using namespace OC::Bridging;
 
@@ -80,9 +79,10 @@ OCEntityHandlerResult resourceEntityHandler(OCEntityHandlerFlag flag,
 
 static LifxLightSharedPtr getLifXLightFromOCFResourceUri(std::string resourceUri);
 
-FILE *lifxSecurityFile(const char *, const char *mode)
+FILE *lifxSecurityFile(const char *path, const char *mode)
 {
-    return fopen(CRED_FILE, mode);
+    std::string filename = std::string("lifx_") + path;
+    return fopen(filename.c_str(), mode);
 }
 
 MPMResult pluginCreate(MPMPluginCtx **pluginSpecificCtx)
index aaf969c..f2043f3 100644 (file)
@@ -122,11 +122,10 @@ OCRepPayload *getPayload(const std::string uri, const THERMOSTAT &data);
 
 void *accessTokenMonitorThread(void *pointer);
 
-static const char CRED_FILE[] = "./oic_svr_db_lyric.dat";
-
-FILE *honeywellFopen(const char *, const char *mode)
+FILE *honeywellFopen(const char *path, const char *mode)
 {
-    return fopen(CRED_FILE, mode);
+    std::string filename = std::string("lyric_") + path;
+    return fopen(filename.c_str(), mode);
 }
 
 MPMPluginCtx *g_pluginCtx = NULL;
index adceb52..c6b4fd8 100644 (file)
@@ -76,11 +76,10 @@ typedef struct
 static const std::string NEST_THERMOSTAT_IF = "oic.if.a";
 static const std::string NEST_THERMOSTAT_RT = "oic.r.temperature";
 
-static const char CRED_FILE[] = "./oic_svr_db_nest.dat";
-
-FILE *nestSecurityFile(const char *, const char *mode)
+FILE *nestSecurityFile(const char *path, const char *mode)
 {
-    return fopen(CRED_FILE, mode);
+    std::string filename = std::string("nest_") + path;
+    return fopen(filename.c_str(), mode);
 }
 
 /*******************************************************************************
index 51de37b..b8f26c4 100644 (file)
 #define TAG "STUB_PLUGIN"
 
 MPMPluginCtx *g_plugin_ctx = NULL;
-static char CRED_FILE[] = "./oic_svr_db_sample.dat";
 
 FILE *sec_file(const char *, const char *mode)
 {
-    return fopen(CRED_FILE, mode);
+    std::string filename = "sample_" + path;
+    return fopen(filename.c_str(), mode);
 }
 
 MPMResult pluginCreate(MPMPluginCtx **pluginSpecificCtx)