Fix for crashing, and proper handling of json-c arrays
authorMichael Carpenter <malcom2073@gmail.com>
Sat, 16 Mar 2013 18:49:29 +0000 (14:49 -0400)
committerMichael Carpenter <malcom2073@gmail.com>
Sat, 16 Mar 2013 18:49:29 +0000 (14:49 -0400)
CMakeLists.txt
lib/CMakeLists.txt
plugins/websocketsink/websocketsinkmanager.cpp
plugins/websocketsourceplugin/websocketsource.cpp

index 204361a..f790ec2 100644 (file)
@@ -53,8 +53,10 @@ endif(libtool_LIBRARY)
 
 find_package(Boost REQUIRED)
 
-pkg_check_modules(glib REQUIRED glib-2.0)
-pkg_check_modules(json REQUIRED json-glib-1.0)
+
+pkg_check_modules(glib REQUIRED glib-2.0 gobject-2.0)
+pkg_check_modules(json REQUIRED json)
+
 
 add_definitions(-std=c++0x)
 add_definitions(-DDBusServiceName="org.automotive.message.broker")
index 12d5a38..15f019d 100644 (file)
@@ -14,7 +14,7 @@ endif(uuid_LIBRARY)
 
 include_directories( ${include_dirs} ${uuid_INCLUDE_DIR})
 
-target_link_libraries(amb ${libtool_LIBRARY} ${glib_LIBRARIES} ${gio_LIBRARIES} ${uuid_LIBRARY})
+target_link_libraries(amb ${libtool_LIBRARY} ${glib_LIBRARIES} ${gio_LIBRARIES} ${uuid_LIBRARY} ${json_LIBRARY})
 
 configure_file (${CMAKE_CURRENT_SOURCE_DIR}/automotive-message-broker.pc.in ${CMAKE_CURRENT_BINARY_DIR}/automotive-message-broker.pc @ONLY)
 
index 996b0e1..b21649c 100644 (file)
@@ -599,7 +599,7 @@ static int websocket_callback(struct libwebsocket_context *context,struct libweb
                                                        data.push_back(path);
                                                }
                                        }
-                                       array_list_free(arraylist);
+                                       //array_list_free(arraylist);
                                }
                                else
                                {
index c335f2f..9bca919 100644 (file)
@@ -283,9 +283,9 @@ static int callback_http_only(libwebsocket_context *context,struct libwebsocket
                        {
                                json_object *dataobject = json_object_object_get(rootobject,"data");
                                
-                               json_object *valueobject = json_object_object_get(rootobject,"value");
-                               json_object *timestampobject = json_object_object_get(rootobject,"timestamp");
-                               json_object *sequenceobject= json_object_object_get(rootobject,"sequence");
+                               json_object *valueobject = json_object_object_get(dataobject,"value");
+                               json_object *timestampobject = json_object_object_get(dataobject,"timestamp");
+                               json_object *sequenceobject= json_object_object_get(dataobject,"sequence");
                                
                                string value = string(json_object_get_string(valueobject));
                                string timestamp = string(json_object_get_string(timestampobject));
@@ -351,7 +351,7 @@ static int callback_http_only(libwebsocket_context *context,struct libwebsocket
                                                        json_object *arrayobj = (json_object*)array_list_get_idx(dataarray,i);
                                                        props.push_back(string(json_object_get_string(arrayobj)));
                                                }
-                                               array_list_free(dataarray);
+                                               //array_list_free(dataarray);
                                        }
                                        else
                                        {
@@ -381,7 +381,7 @@ static int callback_http_only(libwebsocket_context *context,struct libwebsocket
                                                propertylist.push_back(type);
                                                //props.push_back(string(json_object_get_string(arrayobj)));
                                        }
-                                       array_list_free(dataarray);
+                                       //array_list_free(dataarray);
                                        if (source->uuidRangedReplyMap.find(id) != source->uuidRangedReplyMap.end())
                                        {
                                                source->uuidRangedReplyMap[id]->values = propertylist;