Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions src/webcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,7 @@ void *WebConfigMultipartTask(void *status)
struct timespec ts;
Status = (unsigned long)status;

#ifdef _ONESTACK_PRODUCT_REQ_
WebcfgDebug("OneStack build detected. Selecting WebConfig properties based on DeviceMode\n");
char *propFile = getWebcfgPropsFileBasedOnDeviceMode();
initWebcfgProperties(propFile);

#else
initWebcfgProperties(WEBCFG_PROPERTIES_FILE);
#endif

//start webconfig notification thread.
initWebConfigNotifyTask();
Expand Down Expand Up @@ -961,40 +954,3 @@ void JoinThread (pthread_t threadId)
WebcfgError("Error joining thread threadId\n");
}
}

#ifdef _ONESTACK_PRODUCT_REQ_
char* getWebcfgPropsFileBasedOnDeviceMode(void)
{
char *DeviceMode = NULL;
char *propFile = WEBCFG_PROPS_RESIDENTIAL_FILE;

DeviceMode = getDeviceMode();
if (DeviceMode == NULL)
{
setDeviceMode("residential");
WebcfgError("DeviceMode is NULL, defaulting to residential mode, loading %s\n", propFile);
}
else if (strcmp(DeviceMode, "business") == 0)
{
propFile = WEBCFG_PROPS_COMMERCIAL_FILE;
setDeviceMode(DeviceMode);
WebcfgInfo("DeviceMode is %s, loading %s\n", DeviceMode, propFile);
}
else if (strcmp(DeviceMode, "residential") == 0)
{
setDeviceMode(DeviceMode);
WebcfgInfo("DeviceMode is %s, loading %s\n", DeviceMode, propFile);
}
else
{
setDeviceMode("residential");
WebcfgError("Invalid DeviceMode %s, defaulting to residential mode, loading %s\n", DeviceMode, propFile);
}

if (DeviceMode != NULL)
{
WEBCFG_FREE(DeviceMode);
}
return propFile;
}
#endif
3 changes: 0 additions & 3 deletions src/webcfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,4 @@ void set_cloud_forcesync_retry_needed(int value);
int get_cloud_forcesync_retry_needed();
void set_cloud_forcesync_retry_started(int value);
int get_cloud_forcesync_retry_started();
#ifdef _ONESTACK_PRODUCT_REQ_
char* getWebcfgPropsFileBasedOnDeviceMode(void);
#endif
#endif
10 changes: 0 additions & 10 deletions src/webcfg_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,10 @@
/* Macros */
/*----------------------------------------------------------------------------*/
#ifdef BUILD_YOCTO
#ifdef _ONESTACK_PRODUCT_REQ_
#define WEBCFG_PROPS_COMMERCIAL_FILE "/etc/webconfig.properties.commercial"
#define WEBCFG_PROPS_RESIDENTIAL_FILE "/etc/webconfig.properties.residential"
#else
#define WEBCFG_PROPERTIES_FILE "/etc/webconfig.properties"
#endif
#else
#ifdef _ONESTACK_PRODUCT_REQ_
#define WEBCFG_PROPS_COMMERCIAL_FILE "/tmp/webconfig.properties.commercial"
#define WEBCFG_PROPS_RESIDENTIAL_FILE "/tmp/webconfig.properties.residential"
#else
#define WEBCFG_PROPERTIES_FILE "/tmp/webconfig.properties"
#endif
#endif

/*----------------------------------------------------------------------------*/
/* Data Structures */
Expand Down
27 changes: 13 additions & 14 deletions src/webcfg_multipart.c
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,8 @@ void createCurlHeader( struct curl_slist *list, struct curl_slist **header_list,
size_t supplementary_docs_size = 0;
#ifdef _ONESTACK_PRODUCT_REQ_
char *DeviceMode_header = NULL;
#endif
char *DeviceMode = NULL;
#endif

WebcfgDebug("Start of createCurlheader\n");
//Fetch auth JWT token from cloud.
Expand Down Expand Up @@ -1885,6 +1886,17 @@ void createCurlHeader( struct curl_slist *list, struct curl_slist **header_list,
WebcfgError("Failed to get ModelName\n");
}
#ifdef _ONESTACK_PRODUCT_REQ_
if(strlen(g_DeviceMode) ==0)
{
DeviceMode = getDeviceMode();
if(DeviceMode != NULL)
{
strncpy(g_DeviceMode, DeviceMode, sizeof(g_DeviceMode)-1);
WebcfgDebug("g_DeviceMode fetched is %s\n", g_DeviceMode);
WEBCFG_FREE(DeviceMode);
}
}

if(strlen(g_DeviceMode))
{
DeviceMode_header = (char *) malloc(sizeof(char)*MAX_BUF_SIZE);
Expand Down Expand Up @@ -2654,16 +2666,3 @@ void setForceSyncTransID(char *ForceSyncTransID)
const char* getForceSyncTransID() {
return g_ForceSyncTransID;
}

#ifdef _ONESTACK_PRODUCT_REQ_
void setDeviceMode(char *mode)
{
if (mode == NULL)
{
snprintf(g_DeviceMode, sizeof(g_DeviceMode), "residential");
return;
}

snprintf(g_DeviceMode, sizeof(g_DeviceMode), "%s", mode);
}
#endif
4 changes: 0 additions & 4 deletions src/webcfg_multipart.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ typedef struct multipartdocs
struct multipartdocs *next;
} multipartdocs_t;

#ifdef _ONESTACK_PRODUCT_REQ_
void setDeviceMode(char *mode);
#endif

int readFromFile(char *filename, char **data, int *len);
WEBCFG_STATUS parseMultipartDocument(void *config_data, char *ct , size_t data_size, char* trans_uuid);
WEBCFG_STATUS print_tmp_doc_list(size_t mp_count);
Expand Down
37 changes: 3 additions & 34 deletions tests/test_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ int writeToFile(char *file_path, char *data, size_t size)
return 0;
}
}
#ifdef _ONESTACK_PRODUCT_REQ_
char* getWebcfgPropsFileBasedOnDeviceMode(void)
{
char *propFile = WEBCFG_PROPS_RESIDENTIAL_FILE;
return propFile;
}
#endif

/*----------------------------------------------------------------------------*/
/* Test Functions */
/*----------------------------------------------------------------------------*/
Expand All @@ -69,21 +63,6 @@ void test_initWebcfgProperties()
{
char buf[512] = {'\0'};
snprintf(buf,sizeof(buf),"WEBCONFIG_SUPPORTED_DOCS_BIT=00000000000000000000000000000000|00000000000000000000000000000000");
#ifdef _ONESTACK_PRODUCT_REQ_
char *propFile = getWebcfgPropsFileBasedOnDeviceMode();
int out = writeToFile(propFile, buf, strlen(buf));
CU_ASSERT_EQUAL(out, 1);
initWebcfgProperties(propFile);

snprintf(buf,sizeof(buf),"WEBCONFIG_DOC_SCHEMA_VERSION=1234-v0,2345-v0");
out = writeToFile(propFile, buf, strlen(buf));
CU_ASSERT_EQUAL(out, 1);
initWebcfgProperties(propFile);

snprintf(buf,sizeof(buf),"WEBCONFIG_SUBDOC_MAP=privatessid:1:true,homessid:2:true,radio:3:false");
writeToFile(propFile, buf, strlen(buf));
initWebcfgProperties(propFile);
#else
int out = writeToFile(WEBCFG_PROPERTIES_FILE, buf, strlen(buf));
CU_ASSERT_EQUAL(out, 1);
initWebcfgProperties(WEBCFG_PROPERTIES_FILE);
Expand All @@ -94,26 +73,16 @@ void test_initWebcfgProperties()
initWebcfgProperties(WEBCFG_PROPERTIES_FILE);

snprintf(buf,sizeof(buf),"WEBCONFIG_SUBDOC_MAP=privatessid:1:true,homessid:2:true,radio:3:false");
writeToFile(WEBCFG_PROPERTIES_FILE, buf, strlen(buf));
initWebcfgProperties(WEBCFG_PROPERTIES_FILE);
#endif
writeToFile(WEBCFG_PROPERTIES_FILE, buf, strlen(buf));
initWebcfgProperties(WEBCFG_PROPERTIES_FILE);
}

void err_initWebcfgProperties()
{
char command[128] = {'\0'};
#ifdef _ONESTACK_PRODUCT_REQ_
char *propFile = getWebcfgPropsFileBasedOnDeviceMode();
sprintf(command,"rm -rf %s",propFile);
system(command);
initWebcfgProperties(propFile);
#else
sprintf(command,"rm -rf %s",WEBCFG_PROPERTIES_FILE);
system(command);
initWebcfgProperties(WEBCFG_PROPERTIES_FILE);
#endif


}

void test_supportedDocs()
Expand Down
5 changes: 0 additions & 5 deletions tests/test_mul_supp.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ void test_multipart()
printf("\nProvide config URL as argument\n");
return;
}
#ifdef _ONESTACK_PRODUCT_REQ_
char *propFile = getWebcfgPropsFileBasedOnDeviceMode();
initWebcfgProperties(propFile);
#else
initWebcfgProperties(WEBCFG_PROPERTIES_FILE);
#endif
initWebConfigNotifyTask();
processWebcfgEvents();
initEventHandlingTask();
Expand Down
5 changes: 0 additions & 5 deletions tests/test_multipart.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ void test_multipart()
return;
}

#ifdef _ONESTACK_PRODUCT_REQ_
char *propFile = getWebcfgPropsFileBasedOnDeviceMode();
initWebcfgProperties(propFile);
#else
initWebcfgProperties(WEBCFG_PROPERTIES_FILE);
#endif
initWebConfigNotifyTask();
processWebcfgEvents();
initEventHandlingTask();
Expand Down
42 changes: 0 additions & 42 deletions tests/test_webcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,43 +543,7 @@ void test_get_cloud_forcesync_retry_needed()
assert_int_equal(get_cloud_forcesync_retry_needed(), 1);
}

#ifdef _ONESTACK_PRODUCT_REQ_
char *g_mode = NULL;
char *getDeviceMode(void)
{
WebcfgDebug("Inside getDeviceMode weak fn\n");
return g_mode;
}

void test_device_mode_null()
{
WEBCFG_FREE(g_mode);
char *file = getWebcfgPropsFileBasedOnDeviceMode();
assert_string_equal(file, WEBCFG_PROPS_RESIDENTIAL_FILE);
}

void test_device_mode_business()
{
g_mode = strdup("business");
char *file = getWebcfgPropsFileBasedOnDeviceMode();
assert_string_equal(file, WEBCFG_PROPS_COMMERCIAL_FILE);
}

void test_device_mode_residential()
{
g_mode = strdup("residential");
char *file = getWebcfgPropsFileBasedOnDeviceMode();
assert_string_equal(file, WEBCFG_PROPS_RESIDENTIAL_FILE);
}

void test_device_mode_invalid()
{
g_mode = strdup("invalid");
char *file = getWebcfgPropsFileBasedOnDeviceMode();
assert_string_equal(file, WEBCFG_PROPS_RESIDENTIAL_FILE);
}

#endif
/*----------------------------------------------------------------------------*/
/* External Functions */
/*----------------------------------------------------------------------------*/
Expand Down Expand Up @@ -613,12 +577,6 @@ int main(int argc, char *argv[])
cmocka_unit_test(test_get_cloud_forcesync_retry_started),
cmocka_unit_test(test_set_cloud_forcesync_retry_needed),
cmocka_unit_test(test_get_cloud_forcesync_retry_needed),
#ifdef _ONESTACK_PRODUCT_REQ_
cmocka_unit_test(test_device_mode_null),
cmocka_unit_test(test_device_mode_business),
cmocka_unit_test(test_device_mode_residential),
cmocka_unit_test(test_device_mode_invalid),
#endif
};
return cmocka_run_group_tests(tests, NULL, 0);
}
Loading