removed unmaintained plugins
authorKevron Rees <kevron.m.rees@intel.com>
Fri, 5 Dec 2014 17:23:44 +0000 (09:23 -0800)
committerKevron Rees <kevron.m.rees@intel.com>
Fri, 5 Dec 2014 17:23:44 +0000 (09:23 -0800)
25 files changed:
CMakeLists.txt
RELEASE
plugins/CMakeLists.txt
plugins/bluemonkey/irccoms.h
plugins/tpms/CMakeLists.txt [deleted file]
plugins/tpms/README [deleted file]
plugins/tpms/tpmsplugin.cpp [deleted file]
plugins/tpms/tpmsplugin.h [deleted file]
plugins/websocketsink/CMakeLists.txt [deleted file]
plugins/websocketsink/protocol [deleted file]
plugins/websocketsink/test/events.js [deleted file]
plugins/websocketsink/test/index.html [deleted file]
plugins/websocketsink/test/servertest/client.html [deleted file]
plugins/websocketsink/test/servertest/server.html [deleted file]
plugins/websocketsink/test/servertest/server.js [deleted file]
plugins/websocketsink/test/style.css [deleted file]
plugins/websocketsink/test/test.js [deleted file]
plugins/websocketsink/test/vehicle.js [deleted file]
plugins/websocketsink/websocketsink.cpp [deleted file]
plugins/websocketsink/websocketsink.h [deleted file]
plugins/websocketsink/websocketsinkmanager.cpp [deleted file]
plugins/websocketsink/websocketsinkmanager.h [deleted file]
plugins/websocketsourceplugin/CMakeLists.txt [deleted file]
plugins/websocketsourceplugin/websocketsource.cpp [deleted file]
plugins/websocketsourceplugin/websocketsource.h [deleted file]

index b5d8b3e..504ada7 100644 (file)
@@ -23,8 +23,6 @@ set (DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/packages/${PROJECT_NAME}
 
 option(qtmainloop "Use QCoreApplication mainloop " OFF)
 option(websocket_plugin "websocket source and sink plugins" OFF)
-option(websocketold_plugin "old websocket sink plugin" OFF)
-option(tpms_plugin "TPMS plugin " OFF)
 option(obd2_plugin "OBD-II plugin" OFF)
 option(database_plugin "Database plugins" OFF)
 option(qt_bindings "AMB Qt DBus bindings" OFF)
diff --git a/RELEASE b/RELEASE
index 83e6e02..8d818a4 100644 (file)
--- a/RELEASE
+++ b/RELEASE
@@ -1,12 +1,14 @@
 Release notes for release 0.13
 
 New features:
-- [OpenCV plugin] code updated to the new 3.0 API
-- [OpenCV plugin] driver drowsiness detection test code
 - [xwalk extension] implements full W3C automotive BG vehicle and data APIs
+- [OpenCV plugin] code updated to the new 3.0 beta API
+- [OpenCV plugin] driver drowsiness detection test code
 - [Bluemonkey plugin] support for zones in JS API.
+- [Bluemonkey plugin] database module.
 
 Changes:
 - OpenCV plugin experimental options for cuda and kinect are removed
+- Removed unmaintained plugins: tpms, websocket{sink,source}
 
 Fixes:
index f75c527..b7b9b24 100644 (file)
@@ -24,11 +24,8 @@ add_subdirectory(common)
 add_subdirectory(wheel)
 add_subdirectory(dbus)
 add_subdirectory(websocket)
-add_subdirectory(websocketsink)
-add_subdirectory(websocketsourceplugin)
 add_subdirectory(obd2plugin)
 add_subdirectory(demosink)
-add_subdirectory(tpms)
 add_subdirectory(database)
 add_subdirectory(opencvlux)
 add_subdirectory(murphyplugin)
index 0adc53c..cf0ef0b 100644 (file)
@@ -14,7 +14,7 @@ class IrcCommunication: public IrcSession
 {
        Q_OBJECT
        Q_PROPERTY(QStringList channels READ channels WRITE setChannels)
-       Q_PROPERTY(bool ssl WRITE setSsl)
+       Q_PROPERTY(bool ssl READ ssl WRITE setSsl)
 public:
        IrcCommunication(std::map<std::string, std::string> config, QObject* parent=0);
        QStringList channels() { return mChannels; }
@@ -22,6 +22,8 @@ public:
 
        void announceDequeue();
 
+       bool ssl() { return isSecure(); }
+
 public Q_SLOTS:
        void respond(QString target, QString msg);
        void announce(QString);
diff --git a/plugins/tpms/CMakeLists.txt b/plugins/tpms/CMakeLists.txt
deleted file mode 100644 (file)
index c879d43..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-if(tpms_plugin)
-
-  include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs})
-
-  pkg_check_modules(libusb REQUIRED libusb-1.0)
-  set(link_libraries ${link_libraries} ${libusb_LIBRARIES})
-  include_directories(${libusb_INCLUDE_DIRS})
-#check_include_files(libusb.h HAVE_USB)
-#set(CMAKE_CXX_FLAGS "-g -I/usr/include/libusb-1.0/ -lusb-1.0")
-
-  set(tpmsplugin_headers tpmsplugin.h)
-  set(tpmsplugin_sources tpmsplugin.cpp)
-
-  add_library(tpmsplugin MODULE ${tpmsplugin_sources})
-  set_target_properties(tpmsplugin PROPERTIES PREFIX "")
-  target_link_libraries(tpmsplugin amb -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries})
-
-endif(tpms_plugin)
\ No newline at end of file
diff --git a/plugins/tpms/README b/plugins/tpms/README
deleted file mode 100644 (file)
index be4aa49..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-TPMS - Tire Pressure Monitoring System
-
-INTRO
-=====
-This plugin is a source module to support four-wheel tire pressure and temperature reading. 
-Right now, it only supports the USB TPMS module available here:
-http://store.mp3car.com/USB_TPMS_Version_2_20_4_Sensor_Kit_p/com-090.htm (also available 
-on Amazon).
-
-CONFIGURATION
-=============
-The configuration for the module is contained within the source code, so all that is required 
-to run is adding the following source module to an ambd config file:
-    "sources" : [
-        {
-            "name" : "Tpms",
-            "path" : "/usr/local/lib/automotive-message-broker/tpmsplugin.so",
-        }
-    ],
-
-HOW TO USE
-==========
-Depending on system configuration, the ambd module may need to be run as root to get access 
-to the USB driver. Once loaded, the module reads data every 5 seconds for broadcasting. The 
-tire pressure is in kPa and the tire temperature in degrees Celsius.
-
-KNOWN ISSUES
-============
-This is very much an alpha version. Things which should probably be looked at:
-1) Better handling when root access is required
-2) Usage of mode strings from USB module
-3) Generalizing the framework somewhat more to allow usage of other modules (I am not aware 
-of any others with easy USB though)
-4) Pulling hardcoded configuration parameters into the ambd config file, e.g. device pids, 
-which scale to use, read interval, etc.
-5) Others I'm sure...
-
-
-Enjoy!
-Tim Trampedach
-tim@timtt.com
\ No newline at end of file
diff --git a/plugins/tpms/tpmsplugin.cpp b/plugins/tpms/tpmsplugin.cpp
deleted file mode 100644 (file)
index 2dea1fd..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
-Copyright (C) 2012 Intel Corporation
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-#include "tpmsplugin.h"
-
-#include <iostream>
-#include <boost/assert.hpp>
-#include <glib.h>
-#include <libusb.h>
-
-using namespace std;
-
-#include "debugout.h"
-#include "timestamp.h"
-
-#define ENDPOINT_IN             0x81
-#define ENDPOINT_OUT            0x01
-
-#define DEVICE_VID 0x0000
-#define DEVICE_PID 0x0001
-
-#define MAX_SENSORS 4
-
-//timeout for performing interrupt r/w operations in milliseconds
-#define INTR_TIMEOUT 1000
-
-#define PSI_MULTIPLIER 14.5038
-#define KPA_MULTIPLIER 100
-#define PRESSURE_SCALE 0.025
-#define FARENHEIT_MULTIPLIER 1.8
-
-
-static gboolean timeoutCallback(gpointer data)
-{
-       TpmsPlugin* src = (TpmsPlugin*)data;
-       
-       int r = src->readValues();
-
-       return true;
-}
-
-TpmsPlugin::TpmsPlugin(AbstractRoutingEngine* re, map<string, string> config)
-:AbstractSource(re, config)
-{
-    lfPressure = rfPressure = lrPressure = rrPressure = 0;
-    lfTemperature = rfTemperature = lrTemperature = rrTemperature = 0;
-
-    int r = 1;
-    
-    r = libusb_init(NULL);
-    if (r < 0) {
-      DebugOut() << "TPMS: Plugin load failure. Failed to initialize libusb" << endl;
-    }
-    else {
-      r = findDevice();
-      if (r < 0) {
-        DebugOut() << "TPMS: Plugin load failure. Could not find/open device - run as root?" << endl;
-      }
-      else {
-        // need to detach device from kernel driver before claiming the interface
-        r = detachDevice();
-        if (r < 0) {
-          DebugOut() << "TPMS: Plugin load failure. USB device detach failed with code " << r << endl;
-        }
-        else {
-          r = libusb_claim_interface(mDeviceHandle, 0);
-          if (r < 0) {
-            DebugOut() << "TPMS: Plugin load failure. usb_claim_interface error " << r << endl;
-          }
-          else {
-            DebugOut() << "TPMS: USB interface initialized" << endl;   
-
-            re->setSupported(supported(), this);
-            g_timeout_add(5000, timeoutCallback, this );
-            DebugOut() << "TPMS: set to read sensor every 5 seconds" << endl;
-          }
-        }
-      }
-    }
-}
-
-
-extern "C" AbstractSource * create(AbstractRoutingEngine* routingengine, map<string, string> config)
-{
-       return new TpmsPlugin(routingengine, config);
-       
-}
-
-const string TpmsPlugin::uuid()
-{
-       return "5e896a00-15b3-11e3-8ffd-0800200c9a66";
-}
-
-
-void TpmsPlugin::getPropertyAsync(AsyncPropertyReply *reply)
-{
-       DebugOut() << "TPMS: getPropertyAsync called for property: " << reply->property << endl;
-
-    if(reply->property == VehicleProperty::TirePressureLeftFront) {
-         VehicleProperty::TirePressureLeftFrontType temp(lfPressure);
-         reply->success = true;
-      reply->value = &temp;
-      reply->completed(reply);
-    }
-    else if(reply->property == VehicleProperty::TirePressureRightFront) {
-         VehicleProperty::TirePressureRightFrontType temp(rfPressure);
-         reply->success = true;
-      reply->value = &temp;
-      reply->completed(reply);
-    }
-    else if(reply->property == VehicleProperty::TirePressureLeftRear) {
-         VehicleProperty::TirePressureLeftRearType temp(lrPressure);
-         reply->success = true;
-      reply->value = &temp;
-      reply->completed(reply);
-    }
-    else if(reply->property == VehicleProperty::TirePressureRightRear) {
-         VehicleProperty::TirePressureRightRearType temp(rrPressure);
-         reply->success = true;
-      reply->value = &temp;
-      reply->completed(reply);
-    }
-    else if(reply->property == VehicleProperty::TireTemperatureLeftFront) {
-         VehicleProperty::TireTemperatureLeftFrontType temp(lfTemperature);
-         reply->success = true;
-      reply->value = &temp;
-      reply->completed(reply);
-    }
-    else if(reply->property == VehicleProperty::TireTemperatureRightFront) {
-         VehicleProperty::TireTemperatureRightFrontType temp(rfTemperature);
-         reply->success = true;
-      reply->value = &temp;
-      reply->completed(reply);
-    }
-    else if(reply->property == VehicleProperty::TireTemperatureLeftRear) {
-         VehicleProperty::TireTemperatureLeftRearType temp(lrTemperature);
-         reply->success = true;
-      reply->value = &temp;
-      reply->completed(reply);
-    }
-    else if(reply->property == VehicleProperty::TireTemperatureRightRear) {
-         VehicleProperty::TireTemperatureRightRearType temp(rrTemperature);
-         reply->success = true;
-      reply->value = &temp;
-      reply->completed(reply);
-    }
-
-    else {
-      DebugOut() << "TPMS: no such getProperty type: " << reply->property << endl;
-         reply->success = false;
-         reply->error = AsyncPropertyReply::InvalidOperation;
-      reply->value = nullptr;
-      reply->completed(reply);
-       }
-}
-
-void TpmsPlugin::getRangePropertyAsync(AsyncRangePropertyReply *reply)
-{
-       ///not supported
-       reply->completed(reply);
-}
-
-AsyncPropertyReply *TpmsPlugin::setProperty(AsyncSetPropertyRequest request )
-{
-       return NULL;
-}
-
-void TpmsPlugin::subscribeToPropertyChanges(VehicleProperty::Property property)
-{
-       mRequests.push_back(property);
-}
-
-PropertyList TpmsPlugin::supported()
-{
-       PropertyList props;
-    props.push_back(VehicleProperty::TirePressureLeftFront);
-       props.push_back(VehicleProperty::TirePressureRightFront);
-       props.push_back(VehicleProperty::TirePressureLeftRear);
-       props.push_back(VehicleProperty::TirePressureRightRear);
-       props.push_back(VehicleProperty::TireTemperatureLeftFront);
-       props.push_back(VehicleProperty::TireTemperatureRightFront);
-       props.push_back(VehicleProperty::TireTemperatureLeftRear);
-       props.push_back(VehicleProperty::TireTemperatureRightRear);
-       
-       return props;
-}
-
-void TpmsPlugin::unsubscribeToPropertyChanges(VehicleProperty::Property property)
-{
-       mRequests.remove(property);
-}
-
-int TpmsPlugin::findDevice(void)
-{
-  int deviceVid = DEVICE_VID;
-  int devicePid = DEVICE_PID;
-
-  DebugOut() << "TPMS: Trying to open USB device with VID: " << deviceVid << " PID: " << devicePid << endl;
-  mDeviceHandle = libusb_open_device_with_vid_pid(NULL, DEVICE_VID, DEVICE_PID);
-
-  return mDeviceHandle ? 0 : -1;
-}
-
-
-int TpmsPlugin::detachDevice(void)
-{
-  int r;
-  r = libusb_kernel_driver_active(mDeviceHandle, 0);
-  if (r == 1) {
-    DebugOut() << "TPMS: USB device seems to be kernel driven, trying to detach" << endl;
-    r = libusb_detach_kernel_driver(mDeviceHandle, 0);
-  }
-  return r;
-}
-
-
-int TpmsPlugin::exitClean(int deinit)
-{
-  if (deinit) {
-    libusb_release_interface(mDeviceHandle, 0);
-    libusb_attach_kernel_driver(mDeviceHandle, 0);
-    libusb_close(mDeviceHandle);
-  }
-  libusb_exit(NULL);
-}
-
-
-int TpmsPlugin::readValues()
-{
-  int snum;
-  unsigned char buf[4];
-
-  // Sensor 1 = Left Front
-  // Sensor 2 = Right Front
-  // Sensor 3 = Left Rear
-  // Sensor 4 = Right Rear
-
-  for (snum = 1; snum <= MAX_SENSORS; snum++) {
-    readUsbSensor(snum, buf);
-
-    // only do this if sensor is available
-    if (buf[3] != 0xff) {
-      string mode_string;
-      char print_string[100];
-
-      switch (snum) {
-      case 1:
-        lfPressure = ((float)buf[0]-40) * PRESSURE_SCALE * KPA_MULTIPLIER;
-        lfTemperature = (float)buf[1]-40;
-        sprintf(print_string, "TPMS: Left front pressure = %5.1f kPa, temperature = %5.1f degrees Celsius", lfPressure, lfTemperature);
-        DebugOut() << print_string << endl;
-        break;
-      case 2:
-        rfPressure = (buf[0]-40) * PRESSURE_SCALE * KPA_MULTIPLIER;
-        rfTemperature = buf[1]-40;
-        sprintf(print_string, "TPMS: Right front pressure = %5.1f kPa, temperature = %5.1f degrees Celsius", rfPressure, rfTemperature);
-        DebugOut() << print_string << endl;
-        break;
-      case 3:
-        lrPressure = (buf[0]-40) * PRESSURE_SCALE * KPA_MULTIPLIER;
-        lrTemperature = buf[1]-40;
-        sprintf(print_string, "TPMS: Left rear pressure = %5.1f kPa, temperature = %5.1f degrees Celsius", lrPressure, lrTemperature);
-        DebugOut() << print_string << endl;
-        break;
-      case 4:
-        rrPressure = (buf[0]-40) * PRESSURE_SCALE * KPA_MULTIPLIER;
-        rrTemperature = buf[1]-40;
-        sprintf(print_string, "TPMS: Right rear pressure = %5.1f kPa, temperature = %5.1f degrees Celsius", rrPressure, rrTemperature);
-        DebugOut() << print_string << endl;
-        break;
-      }
-
-      // make sensor mode human-readable
-      // FIXME: for future reference, modes not being used
-      switch (buf[3]) {
-        case 0x01: mode_string = "normal"; break;
-        case 0x02: mode_string = "pressure_alert"; break;
-        // more to add here...
-        default: mode_string = "unknown"; break;
-      }
-    }
-    else {
-      DebugOut() << "TPMS: Unable to read sensor " << sensorNumberToString(snum) << " (" << snum << ")" << endl;
-    }
-  }
-
-  VehicleProperty::TirePressureLeftFrontType lfPres(lfPressure);
-  VehicleProperty::TirePressureRightFrontType rfPres(rfPressure);
-  VehicleProperty::TirePressureLeftRearType lrPres(lrPressure);
-  VehicleProperty::TirePressureRightRearType rrPres(rrPressure);
-  VehicleProperty::TireTemperatureLeftFrontType lfTemp(lfTemperature);
-  VehicleProperty::TireTemperatureRightFrontType rfTemp(rfTemperature);
-  VehicleProperty::TireTemperatureLeftRearType lrTemp(lrTemperature);
-  VehicleProperty::TireTemperatureRightRearType rrTemp(rrTemperature);
-
-  routingEngine->updateProperty(&lfPres, uuid());
-  routingEngine->updateProperty(&rfPres, uuid());
-  routingEngine->updateProperty(&lrPres, uuid());
-  routingEngine->updateProperty(&rrPres, uuid());
-  routingEngine->updateProperty(&lfTemp, uuid());
-  routingEngine->updateProperty(&rfTemp, uuid());
-  routingEngine->updateProperty(&lrTemp, uuid());
-  routingEngine->updateProperty(&rrTemp, uuid());
-
-  return 0;
-}
-
-int TpmsPlugin::readUsbSensor(int sid, unsigned char *buf)
-{
-  int r, transferred;
-
-  buf[0] = 0x20 + sid;
-  r = libusb_interrupt_transfer(mDeviceHandle, ENDPOINT_OUT, buf, 1, &transferred, INTR_TIMEOUT);
-  if (r < 0) {
-    DebugOut() << "TPMS: USB write interrupt failed, code " << r << endl;
-  }
-
-  r = libusb_interrupt_transfer(mDeviceHandle, ENDPOINT_IN, buf, 4, &transferred, INTR_TIMEOUT);
-  if (r < 0) {
-    DebugOut() << "TPMS: USB read interrupt failed, code " << r << endl;
-  }
-
-  return r;
-}
-
-
-string TpmsPlugin::sensorNumberToString(int snid)
-{
-  switch (snid) {
-  case 1: return "left front"; break;
-  case 2: return "right front"; break;
-  case 3: return "left rear"; break;
-  case 4: return "right rear"; break;
-  default: return "unknown";
-  }
-}
diff --git a/plugins/tpms/tpmsplugin.h b/plugins/tpms/tpmsplugin.h
deleted file mode 100644 (file)
index 7ed87af..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-Copyright (C) 2012 Tim Trampedach
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-#ifndef TPMSPLUGIN_H
-#define TPMSPLUGIN_H
-
-#include <abstractsource.h>
-#include <string>
-
-using namespace std;
-
-class TpmsPlugin: public AbstractSource
-{
-
-public:
-       TpmsPlugin(AbstractRoutingEngine* re, map<string, string> config);
-       
-       const string uuid();
-       void getPropertyAsync(AsyncPropertyReply *reply);
-       void getRangePropertyAsync(AsyncRangePropertyReply *reply);
-       AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
-       void subscribeToPropertyChanges(VehicleProperty::Property property);
-       void unsubscribeToPropertyChanges(VehicleProperty::Property property);
-       PropertyList supported();
-       
-       void supportedChanged(PropertyList) {}
-
-    int readValues();
-
-       int supportedOperations() { return Get; }
-       
-private:
-       PropertyList mRequests;
-    float lfPressure, rfPressure, lrPressure, rrPressure;
-    float lfTemperature, rfTemperature, lrTemperature, rrTemperature;
-    struct libusb_device_handle *mDeviceHandle;
-
-    int findDevice();
-    int detachDevice();
-    int exitClean(int deinit);
-
-    int readUsbSensor(int sid, unsigned char *buf);
-
-    string sensorNumberToString(int snid);
-};
-
-#endif // TPMSPLUGIN_H
diff --git a/plugins/websocketsink/CMakeLists.txt b/plugins/websocketsink/CMakeLists.txt
deleted file mode 100644 (file)
index d4b1c31..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-if(websocketold_plugin)
-
-include(CheckIncludeFiles)
-include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs})
-
-pkg_check_modules(websockets REQUIRED libwebsockets)
-
-set(websocketsinkplugin_headers websocketsink.h websocketmanager.h)
-set(websocketsinkplugin_sources websocketsinkmanager.cpp websocketsink.cpp)
-add_library(websocketsinkplugin MODULE ${websocketsinkplugin_sources})
-set_target_properties(websocketsinkplugin PROPERTIES PREFIX "")
-target_link_libraries(websocketsinkplugin amb ${websockets_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries})
-
-install(TARGETS websocketsinkplugin LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})
-
-endif(websocketold_plugin)
diff --git a/plugins/websocketsink/protocol b/plugins/websocketsink/protocol
deleted file mode 100644 (file)
index 5250b11..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-Example protocol messages
-
-Property changed event:
-{"type":"valuechanged","name":"VehicleSpeed","data":"217","transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66", "timestamp":"1354521964.60253","sequence":"0"}
-
-Get property request: 
-{"type":"method","name":"get","data":["VehicleSpeed"],"transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} 
-
-Get property reply:
-{"type":"methodReply","name":"get","data":[{"property":"VehicleSpeed","value":"17"}],"transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66", "timestamp" : "1354521964.24962", "sequence": "0" }
-
-Get supported request: 
-{"type":"method","name":"getSupportedEventTypes","data":[],"transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"}
-
-Get supported reply:
-{"type":"methodReply","name":"getSupportedEventTypes","data":["running_status_speedometer","running_status_engine_speed","running_status_steering_wheel_angle","running_status_transmission_gear_status","EngineSpeed","VehicleSpeed","AccelerationX","TransmissionShiftPosition","SteeringWheelAngle","ThrottlePosition","EngineCoolantTemperature","VIN","WMI","BatteryVoltage","MachineGunTurretStatus"],"transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"}
-
-Subscribe to data:
-{"type":"method","name":"subscribe","data":["EngineSpeed"],"transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"}
-
-Subscribe to data reply:
-{"type":"methodReply","name":"subscribe","data":["EngineSpeed"],"transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"}
-
-Get History request:
-{"type":"method","name":"getRange","data": {"timeBegin":"1368825008.35948","timeEnd":"1368825018.35948","sequenceBegin":"-1","sequenceEnd":"-1"},"transactionid":"b07589ba-417c-4604-80c6-01c0dcbd524d"}
diff --git a/plugins/websocketsink/test/events.js b/plugins/websocketsink/test/events.js
deleted file mode 100644 (file)
index cb0cfd5..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0.  The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/* ---------------------- vehicle event typedef --------------------------- */
-
-function VehicleEventType()
-{
-    this.event = [
-"Randomize",
-"AirConditioning",
-"AirRecirculation",
-"AirflowDirection",
-"AvgKW",
-"BatteryStatus",
-"ChildLock",
-"Defrost",
-"ExteriorBrightness",
-"ExteriorTemperature",
-"FanSpeed",
-"FrontWheelRadius",
-"FullBatteryRange",
-"InteriorTemperature",
-"LightHazard",
-"LightHead",
-"LightParking",
-"NightMode",
-"Odometer",
-"SeatHeater",
-"TargetTemperature",
-"TransmissionShiftPosition",
-"VehicleSpeed",
-"Weather"
-    ];
-    this.value = [];
-
-    /* set random initial values for all the props */
-    for(i in this.event)
-    {
-        var prop = this.event[i];
-        this.value[prop] = Math.floor(Math.random() * 1000000);
-    }
-}
-
-VehicleEventType.prototype.getSupportedEventList = function(val)
-{
-    /* for undefined just assume everything */
-    if((val == undefined)||(val === ""))
-        return this.event;
-
-    /* grab every event with case insensitive prefix of val */
-    var value = val.toLowerCase();
-    var list = [];
-    for(i in this.event)
-    {
-        var prop = this.event[i].toLowerCase();
-        if(prop.indexOf(value) === 0)
-        {
-            list[list.length] = prop;
-        }
-    }
-
-    /* if the target val isn't alone, remove it, it's a grouping */
-    var idx = list.indexOf(value);
-    if((idx >= 0)&&(list.length > 1))
-    {
-        list.splice(idx, 1);
-    }
-    return list;
-}
-
-VehicleEventType.prototype.getValueEventList = function(val)
-{
-    var i, j, list = this.getSupportedEventList(val);
-    for(i = 0; i < list.length; i++)
-    {
-        for(j = i + 1; j < list.length; j++)
-        {
-            if(list[j].indexOf(list[i]) === 0)
-            {
-                list.splice(i, 1);
-                i--;
-            }
-        }
-    }
-    return list;
-}
-
-VehicleEventType.prototype.getValuesEventList = function(vals)
-{
-    var i, j, list = [];
-    for(i = 0; i < vals.length; i++)
-    {
-        var sublist = this.getValueEventList(vals[i]);
-        for(j = 0; j < sublist.length; j++)
-        {
-            if(list.indexOf(sublist[j]) < 0)
-            {
-                list[list.length] = sublist[j];
-            }
-        }
-    }
-    return list;
-}
-
-VehicleEventType.prototype.isValueEvent = function(val)
-{
-    var list = this.getValueEventList(val);
-    return(list.length === 1);
-}
-
-VehicleEventType.prototype.getValue = function(prop)
-{
-    return this.value[prop];
-}
-
-VehicleEventType.prototype.isValid = function(prop)
-{
-    return (this.event.indexOf(prop) >= 0);
-}
-
-VehicleEventType.prototype.setValue = function(prop, newval)
-{
-    this.value[prop] = newval;
-}
diff --git a/plugins/websocketsink/test/index.html b/plugins/websocketsink/test/index.html
deleted file mode 100644 (file)
index 9a5daef..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<!doctype html>
-<html lang="en">
-<head>
-    <title>IVI API Tester</title>
-    <meta charset="utf-8">
-    <link rel="stylesheet" href="style.css"/>
-    <script src="vehicle.js"></script>
-</head>
-<body onload="init()">
-    <div id="result">
-    </div>
-    <div id="tester">
-    </div>
-    <script src="events.js"></script>
-    <script src="test.js"></script>
-</body>
-</html>
diff --git a/plugins/websocketsink/test/servertest/client.html b/plugins/websocketsink/test/servertest/client.html
deleted file mode 100644 (file)
index 9ef2ee3..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<!doctype html>
-<html lang="en">
-<head>
-    <title>IVI API Tester</title>
-    <meta charset="utf-8">
-    <link rel="stylesheet" href="../style.css"/>
-    <script src="../api.js"></script>
-</head>
-<body onload='init("ws://localhost:23023/vehicle?client", "")'>
-    <div id="result">
-    </div>
-    <div id="tester">
-    </div>
-    <script src="../events.js"></script>
-    <script src="../test.js"></script>
-</body>
-</html>
diff --git a/plugins/websocketsink/test/servertest/server.html b/plugins/websocketsink/test/servertest/server.html
deleted file mode 100644 (file)
index 43dc72a..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<!doctype html>
-<html lang="en">
-<head>
-    <title>IVI API Server Test</title>
-    <meta charset="utf-8">
-    <style>
-#result {
-    position: absolute;
-    height: 99%;
-    width: 99%;
-    overflow-y: auto;
-    word-wrap: break-word;
-}
-    </style>
-    <script src="../events.js"></script>
-    <script src="server.js"></script>
-</head>
-<body>
-    <div id="result">
-    </div>
-</body>
-</html>
diff --git a/plugins/websocketsink/test/servertest/server.js b/plugins/websocketsink/test/servertest/server.js
deleted file mode 100644 (file)
index 3fcda40..0000000
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0.  The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/* --------------------------- utility code ------------------------------- */
-
-var PRINT = {
-    logElement : null,
-    init : function(log_id) {
-        this.logElement = document.getElementById(log_id);
-    },
-
-    scrollToBottom : function() {
-        this.logElement.scrollTop = this.logElement.scrollHeight;
-    },
-
-    incoming : function(msg) {
-        this.logElement.innerHTML += "<div style='color: blue'> REQUEST: " + msg + "</div>";
-        this.scrollToBottom();
-    },
-
-    outgoing : function(msg) {
-        this.logElement.innerHTML += "<div style='color: purple'> RESPONSE: " + msg + "</div>";
-        this.scrollToBottom();
-    },
-
-    pass : function(msg) {
-        this.logElement.innerHTML += "<div style='color: green'> SUCCESS: " + msg + "</div>";
-        this.scrollToBottom();
-    },
-
-    fail : function(msg) {
-        this.logElement.innerHTML += "<div style='color: red'> FAIL: " + msg + "</div>";
-        this.scrollToBottom();
-    },
-
-    log : function(msg) {
-        this.logElement.innerHTML += "<div class='LogClass'> " + msg + "</div>";
-        this.scrollToBottom();
-    },
-}
-
-/* ----------------------------- test code --------------------------------- */
-
-function VehicleServer(socketUrl)
-{
-    var self = this;
-    this.vehicleEventType = new VehicleEventType();
-    this.subscriptions = [];
-
-    this.Signal = function(name)
-    {
-        var me = this;
-        this.users = 0;
-        this.name = name;
-        this.start = function() {
-            if(me.users <= 0)
-            {
-                var interval = Math.floor(Math.random()*5000) + 1000;
-                me.timer = setInterval(function() {
-                    var value = parseInt(self.vehicleEventType.getValue(me.name)) + 1;
-                    self.vehicleEventType.setValue(me.name, value);
-                    var obj = {
-                        "type" : "valuechanged",
-                        "name": me.name,
-                        "data" : value
-                    };
-                    self.socket.send(JSON.stringify(obj));
-                }, interval);
-            }
-            me.users = 1;
-        }
-        this.stop = function() {
-            me.users--;
-            if((me.users <= 0)&&(me.timer != undefined))
-            {
-                clearInterval(me.timer);
-            }
-        }
-    }
-
-    function init() {
-        if ("WebSocket" in window)
-        {
-            var list = self.vehicleEventType.getValueEventList();
-            for(var i = 0; i < list.length; i++)
-            {
-                self.subscriptions[i] = new self.Signal(list[i]);
-            }
-
-            self.socket = new WebSocket(socketUrl);
-            self.socket.onopen = function()
-            {
-                PRINT.pass("Server READY");
-            };
-            self.socket.onclose = function()
-            {
-                PRINT.fail("Server CLOSED");
-            };
-            self.socket.onerror = function(e)
-            {
-                PRINT.fail("Server ERROR: "+e.data);
-            };
-            self.socket.onmessage = function (e) 
-            {
-                self.receive(e.data);
-            };
-        }
-        else
-        {
-            PRINT.fail("This browser doesn't appear to support websockets!");
-        }
-    }
-    init();
-}
-
-VehicleServer.prototype.subscribe = function(list)
-{
-    for(var i = 0; i < this.subscriptions.length; i++)
-    {
-        if(list.indexOf(this.subscriptions[i].name) >= 0)
-        {
-            this.subscriptions[i].start();
-        }
-    }
-}
-
-VehicleServer.prototype.unsubscribe = function(list)
-{
-    for(var i = 0; i < this.subscriptions.length; i++)
-    {
-        if(list.indexOf(this.subscriptions[i].name) >= 0)
-        {
-            this.subscriptions[i].stop();
-        }
-    }
-}
-
-VehicleServer.prototype.receive = function(msg)
-{
-    var event = JSON.parse(msg);
-    /* accept only methods with transaction ids */
-    if((event == undefined)||(event.transactionid == undefined)||
-       (event.type != "method"))
-    {
-        return;
-    }
-
-    var obj;
-    PRINT.incoming(msg);
-    if(event.name === "getSupportedEventTypes")
-    {
-        var data;
-        if(event.writeable)
-        {
-            data = this.vehicleEventType.getValueEventList(event.data);
-        }
-        else
-        {
-            data = this.vehicleEventType.getSupportedEventList(event.data);
-        }
-        obj = {
-            "type" : "methodReply",
-            "name": event.name,
-            "transactionid" : event.transactionid,
-            "data" : data
-        };
-    }
-    else if(event.name === "get")
-    {
-        var names = this.vehicleEventType.getValuesEventList(event.data);
-        if(names.length > 0)
-        {
-            obj = {
-                "type" : "methodReply",
-                "name": event.name,
-                "transactionid" : event.transactionid,
-                "data" : []
-            };
-            for(i in names)
-            {
-                var value = this.vehicleEventType.getValue(names[i]);
-                obj.data.push({"name" : names[i], "value" : value});
-            }
-        }
-        else
-        {
-            obj = {
-                "type" : "methodReply",
-                "name": event.name,
-                "transactionid" : event.transactionid,
-                "error" : event.data + " is not a valid event"
-            };
-        }
-    }
-    else if(event.name === "set")
-    {
-        var bad = [];
-        var good = [];
-        for(var i = 0; i < event.data.length; i++)
-        {
-            if((event.data[i].value != undefined) && 
-               this.vehicleEventType.isValueEvent(event.data[i].property))
-            {
-                this.vehicleEventType.setValue(event.data[i].property, parseInt(event.data[i].value));
-                good[good.length] = event.data[i].property;
-            }
-            else
-            {
-                bad[bad.length] = event.data[i].property;
-            }
-        }
-
-        obj = {
-            "type" : "methodReply",
-            "name": event.name,
-            "transactionid" : event.transactionid
-        };
-
-        if(bad.length > 0)
-        {
-            obj.error = "Failed to set:";
-            for(var i = 0; i < bad.length; i++)
-            {
-                obj.error += " "+bad[i];
-            }
-        }
-
-        if(good.length > 0)
-        {
-            obj.data = "Successfully set:";
-            for(var i = 0; i < good.length; i++)
-            {
-                obj.data += " "+good[i];
-            }
-        }
-    }
-    else if(event.name === "subscribe")
-    {
-        var names = this.vehicleEventType.getValuesEventList(event.data);
-        if(names.length > 0)
-        {
-            obj = {
-                "type" : "methodReply",
-                "name": event.name,
-                "transactionid" : event.transactionid,
-                "data" : names
-            };
-            for(i in names)
-            {
-                this.subscribe(names[i]);
-            }
-        }
-        else
-        {
-            obj = {
-                "type" : "methodReply",
-                "name": event.name,
-                "transactionid" : event.transactionid,
-                "error" : "no valid events provided"
-            };
-        }
-    }
-    else if(event.name === "unsubscribe")
-    {
-        var names = this.vehicleEventType.getValuesEventList(event.data);
-        if(names.length > 0)
-        {
-            obj = {
-                "type" : "methodReply",
-                "name": event.name,
-                "transactionid" : event.transactionid,
-                "data" : names
-            };
-            for(i in names)
-            {
-                this.unsubscribe(names[i]);
-            }
-        }
-        else
-        {
-            obj = {
-                "type" : "methodReply",
-                "name": event.name,
-                "transactionid" : event.transactionid,
-                "error" : "no valid events provided"
-            };
-        }
-    }
-    else
-    {
-        obj = {
-            "type" : "methodReply",
-            "name": event.name,
-            "transactionid" : event.transactionid,
-            "error" : event.name + " is not a valid method"
-        };
-    }
-    PRINT.outgoing(JSON.stringify(obj));
-    this.socket.send(JSON.stringify(obj));
-}
-
-window.addEventListener('load', function () {
-    "use strict";
-    PRINT.init("result");
-    var server = new VehicleServer("ws://localhost:23023/vehicle?server");
-});
diff --git a/plugins/websocketsink/test/style.css b/plugins/websocketsink/test/style.css
deleted file mode 100644 (file)
index 8456fd1..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-.PassClass {
-    font: bold 16px Arial;
-    color: green;
-}
-
-.FailClass {
-    font: bold 16px Arial;
-    color: red;
-}
-
-.LogClass {
-    font: 16px Arial;
-    color: black;
-}
-
-#tester {
-    position: absolute;
-    -webkit-user-select: none;
-    top: 0px;
-    left: 0%;
-    height: 100%;
-    width: 620px;
-    overflow-y: auto;
-}
-
-#result {
-    position: absolute;
-    top: 0px;
-    left: 620px;
-    height: 98%;
-    width: 1380px;
-    padding-top: 1%;
-    background-color: #eeeeee;
-    padding-left: 1%;
-    word-wrap:break-word;
-    overflow-y: auto;
-}
-
-.proptest {
-    position: relative;
-    left: 0px;
-    height: 67px;
-    width: 700px;
-    overflow: hidden;
-}
-
-.proptest .buttons {
-    position: absolute;
-    top: 32px;
-    left: 0px;
-    height: 35px;
-    width: 630px;
-}
-
-.smallText {
-    text-align: left;
-    color: #FFFFFF;
-    font: 18px Arial;
-    display: inline;
-}
-.propinfo {
-    position: absolute;
-    top: 0px;
-    left: 0px;
-    height: 67px;
-    width: 600px;
-    text-align: left;
-    color: #FFFFFF;
-    font: 18px Arial;
-    line-height: 30px;
-    padding-left: 5px;
-    background: -webkit-gradient(linear, left top, left bottom, from(#444), to(#000));
-    cursor: pointer;
-}
-
-.propinfo.select {
-    background: -webkit-gradient(linear, left top, left bottom, from(#444), to(#aaa));
-}
-
-.propinfo.unselectable {
-    cursor: auto;
-    background: #000000;
-    border-bottom: solid 1px #444;
-}
-
-input[type='text'] {
-    margin-top: 5px;
-    color: black;
-    font: bold 18px Arial;
-    height: 19px;
-    width: 100px;
-    background: -webkit-gradient(linear, left top, left bottom, from(#aaa), to(#fff));
-    -webkit-transition: all 2s linear;
-}
-
-input[type='text'].change {
-    -webkit-transition: all 0.1s linear;
-    color: red;
-}
-
-.testbutton {
-    position: relative;
-    float: left;
-    color: #d7d7d7;
-    border: solid 1px #333;
-    text-align: center;
-    text-decoration: none;
-    font: 16px/100% Arial, Helvetica, sans-serif;
-    text-shadow: 0 1px 1px rgba(0,0,0,.3);
-    -webkit-border-radius: 12px;
-    border-radius: 12px;
-    background: -webkit-gradient(linear, left top, left bottom, from(#666), to(#000));
-    height: 25px;
-    line-height: 24px;
-    cursor: pointer;
-    box-shadow: 2px 2px 14px #000;
-    margin-top: 5px;
-    margin-bottom: 5px;
-    margin-right: 2px;
-}
-
-.testbutton.types {
-    width: 50px;
-    background: -webkit-gradient(linear, left top, left bottom, from(blue), to(#000));
-}
-
-.testbutton.types:after {
-    content: 'types';
-}
-
-.testbutton.get {
-    width: 35px;
-    background: -webkit-gradient(linear, left top, left bottom, from(green), to(#000));
-}
-
-.testbutton.get:after {
-    content: 'get';
-}
-
-.testbutton.set {
-    width: 35px;
-    background: -webkit-gradient(linear, left top, left bottom, from(green), to(#000));
-}
-
-.testbutton.set:after {
-    content: 'set';
-}
-
-.testbutton.subscribe {
-    width: 80px;
-    background: -webkit-gradient(linear, left top, left bottom, from(purple), to(#000));
-}
-
-.testbutton.subscribe.disable {
-    pointer-events: none;
-    color: #999999;
-    background: -webkit-gradient(linear, left top, left bottom, from(#000), to(#111));
-}
-
-.testbutton.subscribe:after {
-    content: 'subscribe';
-}
-
-.testbutton.unsubscribe {
-    width: 100px;
-    background: -webkit-gradient(linear, left top, left bottom, from(purple), to(#000));
-}
-
-.testbutton.unsubscribe.disable {
-    pointer-events: none;
-    color: #999999;
-    background: -webkit-gradient(linear, left top, left bottom, from(#000), to(#111));
-}
-
-.testbutton.unsubscribe:after {
-    content: 'unsubscribe';
-}
-
-.testbutton:active {
-    color: #666;
-    background: -webkit-gradient(linear, left top, left bottom, from(#000), to(#444));
-}
diff --git a/plugins/websocketsink/test/test.js b/plugins/websocketsink/test/test.js
deleted file mode 100644 (file)
index 90106f2..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0.  The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/* --------------------------- utility code ------------------------------- */
-
-var PRINT = {
-    logElement: null,
-    init: function(log_id) {
-        this.logElement = document.getElementById(log_id);
-    },
-
-    scrollToBottom: function() {
-        this.logElement.scrollTop = this.logElement.scrollHeight;
-    },
-
-    clear: function() {
-        this.logElement.innerHTML = "";
-    },
-
-    pass: function(msg) {
-        this.logElement.innerHTML += "<div class='PassClass'>PASS: " + msg + "</div>";
-        this.scrollToBottom();
-    },
-
-    fail: function(msg) {
-        this.logElement.innerHTML += "<div class='FailClass'>FAIL: " + msg + "</div>";
-        this.scrollToBottom();
-    },
-
-    log: function(msg) {
-        this.logElement.innerHTML += "<div class='LogClass'> " + msg + "</div>";
-        this.scrollToBottom();
-    },
-}
-
-/* ----------------------------- test code --------------------------------- */
-
-var vehicleEventType = new VehicleEventType();
-var selected = [];
-
-function getTypes(event) {
-    var types = window.vehicle.getSupportedEventTypes(event, false,
-        function(data) {
-            if (data && data.length > 1) {
-                PRINT.pass(event + " is a set of " + data.length + " events:");
-                for (i in data) {
-                    PRINT.log(data[i]);
-                }
-            } else if (data && data.length > 0) {
-                PRINT.pass(event + " is a single event:");
-                for (i in data) {
-                    PRINT.log(data[i]);
-                }
-            } else {
-                PRINT.fail(event + " unexcepted empty data field");
-            }
-        },
-        function(msg) {
-            PRINT.fail(((event === "") ? "all events" : event) + ":<br>" + msg);
-        }
-    );
-}
-
-function updateInput(input, value) {
-    input.value = value;
-    input.className = "change";
-    input.addEventListener('webkitTransitionEnd', function callback(e) {
-        e.target.removeEventListener('webkitTransitionEnd', callback, false);
-        e.target.className = "";
-    }, false);
-}
-
-function getValue(eventlist) {
-    var zoneList =  getZone(eventlist);
-    var types = window.vehicle.get(eventlist, zoneList,
-        function(data) {
-            if (data) {
-                PRINT.pass("values received:");
-                if (eventlist.length > 1 && !! data.length && data.length > 0) {
-                    var list = [];
-                    for (var i = 0; i < data.length; i++) {
-                        list[i] = data[i].property;
-                        //list[i] = data[i].name; ???
-                        PRINT.log(data[i].property + ": " + data[i].value + ", zone: " + data[i].zone);
-                        //PRINT.log(data[i].name+": "+data[i].value); ???
-                    }
-
-                    var elements = document.getElementsByClassName('proptest');
-                    for (var i = 0; i < elements.length; i++) {
-                        var propinfo = elements[i].getElementsByClassName('propinfo')[0];
-                        var name = propinfo.innerHTML;
-                        var idx = list.indexOf(name);
-                        if (idx >= 0) {
-                            var zone = elements[i].getElementsByTagName('input')[1];
-                            updateInput(zone, zone.value);
-                            var input = elements[i].getElementsByTagName('input')[0];
-                            updateInput(input, data[idx].value);
-                        }
-                    }
-                } else {
-                    PRINT.log(JSON.stringify(data));
-                    var elements = document.getElementsByClassName('proptest');
-                    for (var i = 0; i < elements.length; i++) {
-                        var propinfo = elements[i].getElementsByClassName('propinfo')[0];
-                        if (data.property == propinfo.innerHTML) {
-                            var zone = elements[i].getElementsByTagName('input')[1];
-                            updateInput(zone, zone.value);
-                            var input = elements[i].getElementsByTagName('input')[0];
-                            updateInput(input, data.value);
-                        }
-                    }
-                }
-            } else {
-                PRINT.fail("no values retrieved for " + eventlist);
-            }
-        },
-        function(msg) {
-            PRINT.fail(msg);
-        }
-    );
-}
-
-function setValue(eventlist) {
-    var zoneList =  getZone(eventlist);
-    var elements = document.getElementsByClassName('proptest');
-    var i, valuelist = [] ;
-
-    /* initialize the value list */
-    for (i = 0; i < eventlist.length; i++) {
-        valuelist[i] = 0;
-    }
-
-    for (var i = 0; i < elements.length; i++) {
-        var propinfo = elements[i].getElementsByClassName('propinfo')[0];
-        var name = propinfo.innerHTML;
-        var idx = eventlist.indexOf(name);
-        if (idx >= 0) {
-
-            var input = elements[i].getElementsByTagName('input')[0];
-            valuelist[idx] = input.value;
-        }
-    }
-
-    var types = window.vehicle.set(eventlist, valuelist, zoneList, 
-        function(msg) {
-            PRINT.pass("Set success for: " + JSON.stringify(msg));
-        },
-        function(msg) {
-            PRINT.fail("Set error: " + JSON.stringify(msg));
-        }
-    );
-}
-
-function eventListener(e) {
-       PRINT.log(e.name + " update: " + JSON.stringify(e.value));
-    var elements = document.getElementsByClassName('proptest');
-    for (var i = 0; i < elements.length; i++) {
-        var propinfo = elements[i].getElementsByClassName('propinfo')[0];
-        var name = propinfo.innerHTML;
-        if (name === e.name) {
-            var input = elements[i].getElementsByTagName('input')[0];
-            updateInput(input, e.value.value);
-            var zone = elements[i].getElementsByTagName('input')[1];
-            updateInput(zone, e.value.zone);
-        }
-    }
-}
-
-function subscribe(eventlist) {
-   var zoneList =  getZone(eventlist);
-    window.vehicle.subscribe(eventlist, zoneList,
-        function(data) {
-            PRINT.pass("Subscribe success for: " + data);
-            for (var i = 0; i < data.length; i++) {
-                var sub = data[i] + "_subscribe";
-                var unsub = data[i] + "_unsubscribe";
-                //                document.getElementById(sub).className = "testbutton subscribe disable"
-                //                document.getElementById(unsub).className = "testbutton unsubscribe";
-                document.addEventListener(data[i], eventListener, false);
-            }
-        },
-        function(msg) {
-            PRINT.fail("Subscribe failed for: " + msg);
-        }
-    );
-}
-
-function unsubscribe(eventlist, zoneList) {
-    zoneList =  getZone(eventlist);
-    /* kill the handers first, so even if the service fails to acknowledge */
-    /* we've stopped listening */
-    for (var i = 0; i < eventlist.length; i++) {
-        document.removeEventListener(eventlist[i], eventListener, false);
-    }
-    window.vehicle.unsubscribe(eventlist, zoneList,
-        function(data) {
-            PRINT.pass("Unsubscribe success for: " + data);
-            for (var i = 0; i < data.length; i++) {
-                var sub = data[i] + "_subscribe";
-                var unsub = data[i] + "_unsubscribe";
-                //                document.getElementById(unsub).className = "testbutton unsubscribe disable";
-                //                document.getElementById(sub).className = "testbutton subscribe";
-            }
-        },
-        function(msg) {
-            PRINT.fail("Unsubscribe failed for: " + msg);
-        }
-    );
-}
-
-function getZone(eventlist) {
-    var list = [];
-    if (eventlist.length > 1) {
-
-        // for (var i = 0; i < data.length; i++) {
-        //     list[i] = data[i].property;
-        //     //list[i] = data[i].name; ???
-        //     PRINT.log(data[i].property + ": " + data[i].value);
-        //     //PRINT.log(data[i].name+": "+data[i].value); ???
-        // }
-
-        var elements = document.getElementsByClassName('proptest');
-        for (var i = 0; i < elements.length; i++) {
-            var propinfo = elements[i].getElementsByClassName('propinfo')[0];
-            var name = propinfo.innerHTML;
-            var idx = eventlist.indexOf(name);
-            if (idx >= 0) {
-                var zone = elements[i].getElementsByTagName('input')[1];
-                list.push(zone.value);
-            }
-        }
-    } else {
-        var elements = document.getElementsByClassName('proptest');
-        for (var i = 0; i < elements.length; i++) {
-            var propinfo = elements[i].getElementsByClassName('propinfo')[0];
-            if (eventlist[0] == propinfo.innerHTML) {
-                var zone = elements[i].getElementsByTagName('input')[1];
-                list.push(zone.value);
-            }
-        }
-    }
-    return list.join();
-}
-
-function select(elem) {
-    var name = elem.innerHTML;
-    if (!vehicleEventType.isValid(name))
-        return;
-
-    var idx = selected.indexOf(name);
-    if (elem.className == "propinfo") {
-        if (idx < 0) {
-            selected[selected.length] = name;
-        }
-        elem.className = "propinfo select";
-    } else if (elem.className == "propinfo select") {
-        if (idx >= 0) {
-            selected.splice(idx, 1);
-        }
-        elem.className = "propinfo";
-    }
-}
-
-function start(msg) {
-    if (window.vehicle && window.vehicle.getSupportedEventTypes) {
-        PRINT.pass("vehicle interface online " + msg);
-    } else {
-        PRINT.fail("vehicle interface not found");
-        return;
-    }
-
-    var tester = document.getElementById("tester");
-    var part = ['<div class="proptest"><div class="propinfo" onclick=select(this)>',
-        '</div><div class="buttons"><div class="testbutton types" onclick=getTypes("',
-        '")></div><div id="',
-        '_subscribe" class="testbutton subscribe" onclick=subscribe(["',
-        '"])></div><div id="',
-        '_unsubscribe" class="testbutton unsubscribe" onclick=unsubscribe(["',
-        '"])></div><div class="testbutton get" onclick=getValue(["',
-        '"])></div><div class="testbutton set" onclick=setValue(["',
-        '"])></div><input class = "Textvalue" type="text" value="0" placeholder="Value" /><div class = "smallText"> Zone: </div><input class = "zone" type="text" value="0" placeholder="Zone"/></div></div>'
-    ];
-    var events = vehicleEventType.event;
-
-    /* apply on all selected events */
-    var html = '<div class="proptest"><div class="propinfo unselectable">apply on all selected events' +
-        '</div><div class="buttons">' +
-        '<div class="testbutton subscribe" onclick=subscribe(selected)></div>' +
-        '<div class="testbutton unsubscribe" onclick=unsubscribe(selected)></div>' +
-        '<div class="testbutton get" onclick=getValue(selected)></div>' +
-        '<div class="testbutton set" onclick=setValue(selected)></div></div></div>';
-
-    /* all events */
-    html += '<div class="proptest"><div class="propinfo unselectable">all events';
-    html +=     '</div><div class="buttons"><div class="testbutton types" onclick=getTypes("' ;
-    html +=     '")></div><div class="testbutton subscribe" onclick=\"subscribe([\'' ;
-    html +=     events.join("','") ;
-    html +=     '\'])\"></div><div class="testbutton unsubscribe" onclick= \"unsubscribe([\'' ;
-    html +=     events.join("','");
-    html +=     '\'])\"></div><div class="testbutton get" onclick=\"getValue([\'' ;
-    html +=     events.join("','");
-    html +=     '\'])\"></div></div></div>';
-
-    /* events */
-    for (var i = 0; i < events.length; i++) {
-        var piece = "";
-        for (var j = 0; j < part.length - 1; j++) {
-            piece += part[j] + events[i];
-        }
-        html += piece + part[j];
-    }
-    tester.innerHTML = html;
-}
-
-function error(msg) {
-    PRINT.fail(msg);
-}
-
-function init(url, protocol) {
-    PRINT.init("result");
-    window.vehicle = new Vehicle(start, error, url, protocol);
-}
diff --git a/plugins/websocketsink/test/vehicle.js b/plugins/websocketsink/test/vehicle.js
deleted file mode 100644 (file)
index 6b8e600..0000000
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
- * Copyright (c) 2012, Intel Corporation.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0.  The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-/*****************************************************************************
-* Class name: Vehicle
-* Description:
-*    A javascript implementation of the IVI vehicle API that communicates
-*    to the automotive message broker through a websocket
-* Optional constructor arguments:
-*    sCB: success callback, called when socket is connected, argument is 
-*         success message string
-*    eCB: error callback, called on socket close or error, argument is error
-*         message string
-*    url: the URL to use for the websocket, in the form "ws://host:port/script"
-*    protocol: the protocol to use for the websocket, default is "http-only"
-*
-* [Public Member functions]
-*  Function name: getSupportedEventTypes(type, writeable, successCB, errorCB)
-*    Description:
-*        Retrieves a list of vehicle events for the requested type
-*    Required arguments:
-*        type: target event or group to query (use empty string for all events)
-*        writeable: if true, return only writeable events, otherwise get all
-*        successCB: success callback, gets called with a string list of names
-*              for all the events and event groups that are children of the 
-*              target. e.g. "vehicle_info" returns all events/groups with the 
-*              vehicle_info prefix. If the target is an event group, it's
-*              omitted from the returned list
-*        errorCB: error callback, called with error message string
-*
-*  Function name: get(eventlist, successCB, errorCB)
-*    Description:
-*        Retrieves a list of event/value pairs for a target list of event names
-*    Required arguments:
-*        eventlist[]: list of events to read (use empty string for all events)
-*        successCB: success callback, gets called with the event/value pair list
-*                   for all requested events. The list is the in the 
-*                   form of data[n].name/data[n].value
-*        errorCB: error callback, called with error message string
-*
-*  Function name: getHistory(event, startTime, endTime, successCB, errorCB)
-*    Description:
-*        Retrieves a list of event/value pairs for a target list of event names
-*    Required arguments:
-*        event: event to read
-*        startTime: start date/time
-*        endTime: end date/time
-*        successCB: success callback, gets called with the event/value pair list
-*                   for all requested events. The list is the in the
-*                   form of data[n].name/data[n].value
-*        errorCB: error callback, called with error message string
-*
-*
-*  Function name: set(eventlist, valuelist, successCB, errorCB)
-*    Description:
-*        Sets a gourp of event's values (triggers error on read-only events)
-*    Required arguments:
-*        eventlist: target events to set
-*        valuelist: target event values
-*        successCB: success callback, gets called with the eventlist
-*                   that was successfully set
-*        errorCB: error callback, called with error message string
-*
-*  Function name: subscribe(eventlist, successCB, errorCB)
-*    Description:
-*        Subscribe to a list of events so you can listen to value changes, they
-*        can be monitored with document.addEventListener(eventname, callback, false);
-*        The Event object passed to the callback has two parameters, e.name and 
-*        e.value. Events are sent to the handler individually.
-*    Required arguments:
-*        eventlist: target events to listen to
-*        successCB: success callback, gets called with the eventlist
-*                   that was successfully subscribed
-*        errorCB: error callback, called with the eventlist that failed to subscribe
-*
-*  Function name: unsubscribe(eventlist, successCB, errorCB)
-*    Description:
-*        Unsubscribe to a list of events to let the server know you're not listening, 
-*        they should stop being sent from the server if no other clients are using them,
-*        but will at least stop being triggered in your app.
-*    Required arguments:
-*        eventlist: target events to stop listening to
-*        successCB: success callback, gets called with the eventlist
-*                   that was successfully unsubscribed
-*        errorCB: error callback, called with the eventlist that failed to unsubscribe
-*
-******************************************************************************/
-/*
-(function () {
-*/
-function Vehicle(sCB, eCB, url, protocol)
-{
-    /* store a copy of Vehicle this for reference in callbacks */
-    var self = this;
-
-    this.iSuccessCB = sCB;
-    this.iErrorCB = eCB;
-
-    /* variables for call management, supports up to 100 simultaneously */
-    this.methodIdx = 0;
-    this.methodCalls = [];
-    for(var i = 0; i < 100; i++)
-    {
-        this.methodCalls[i] = null;
-    }
-
-    /* number of connection retries to attempt if the socket closes */
-    this.retries = 5;
-    this.connected = false;
-
-    /* timeout for method calls in milliseconds */
-    this.timeouttime = 5000;
-
-    /* default values for WebSocket */
-    this.socketUrl = "ws://localhost:23000/vehicle";
-    this.socketProtocol = "http-only";
-
-    /* override the websocket address if parameters are given */
-    if(url !== undefined) this.socketUrl = url;
-    if(protocol !== undefined) this.socketProtocol = protocol;
-
-    this.VehicleMethodCall = function(id, name, successCB, errorCB)
-    {
-        var me = this;
-        this.successCB = successCB;
-        this.errorCB = errorCB;
-        this.transactionid = id;
-        this.name = name;
-        this.done = false;
-        this.start = function()
-        {
-            me.timeout = setTimeout(function(){
-                if(me.errorCB !== undefined)
-                {
-                    me.errorCB("\""+me.name+"\" method timed out after "+self.timeouttime+"ms");
-                }
-                me.finish();
-            }, self.timeouttime);
-        }
-        this.finish = function()
-        {
-            if(me.timeout !== undefined)
-            {
-                clearTimeout(me.timeout);
-            }
-            me.done = true;
-        }
-    }
-
-    function init() {
-        if ("WebSocket" in window)
-        {
-            if(self.socketProtocol.length > 0)
-            {
-                self.socket = new WebSocket(self.socketUrl, self.socketProtocol);
-            }
-            else
-            {
-                self.socket = new WebSocket(self.socketUrl);
-            }
-            self.socket.onopen = function()
-            {
-                self.connected = true;
-                self.iSuccessCB((self.retries < 5)?"(RECONNECTED)":"");
-                self.retries = 5;
-            };
-            self.socket.onclose = function()
-            {
-                self.connected = false;
-                self.iErrorCB("socket closed "+((self.retries > 0)?"retrying in 5 seconds ...":""));
-                if(self.retries > 0)
-                {
-                    setTimeout(function(){
-                        self.retries--;
-                        init();
-                    }, 5000);
-                }
-            };
-            self.socket.onerror = function(e)
-            {
-                self.iErrorCB(e.data);
-            };
-            self.socket.onmessage = function (e) 
-            {
-                self.receive(e.data);
-            };
-        }
-        else
-        {
-            console.log("This browser doesn't appear to support websockets!");
-        }
-    }
-    init();
-}
-
-Vehicle.prototype.generateTransactionId = function()
-{
-    var i, val = [];
-    for(i = 0; i < 8; i++)
-    {
-       var num = Math.floor((Math.random()+1)*65536);
-       val[i] = num.toString(16).substring(1);
-    }
-    var uuid = val[0]+val[1]+"-"+
-               val[2]+"-"+val[3]+"-"+val[4]+"-"+
-               val[5]+val[6]+val[7];
-    return uuid;
-}
-
-Vehicle.prototype.send = function(obj, successCB, errorCB)
-{
-    if(!this.connected)
-    {
-        if(errorCB !== undefined)
-        {
-            errorCB("\""+obj.name+"\" method failed because socket is closed");
-        }
-        return;
-    }
-    var i = this.methodIdx;
-    this.methodIdx = (this.methodIdx + 1)%100;
-    this.methodCalls[i] = new this.VehicleMethodCall(obj.transactionid, 
-        obj.name, successCB, errorCB);
-    this.socket.send(JSON.stringify(obj));
-    this.methodCalls[i].start();
-}
-
-
-Vehicle.prototype.getSupportedEventTypes = function(type, writeable, successCB, errorCB)
-{
-    var obj = {
-        "type" : "method",
-        "name" : "getSupportedEventTypes",
-        "writeable" : writeable,
-        "transactionid" : this.generateTransactionId(),
-        "data" : type
-    };
-    this.send(obj, successCB, errorCB);
-}
-
-Vehicle.prototype.get = function(namelist, zone, successCB, errorCB)
-{
-    if(namelist.length <= 0)
-    {
-        return;
-    }
-
-       var properties = [];
-
-    for(var i = 0; i < namelist.length; i++)
-    {
-        properties[i] = {"property" : namelist[i], "zone" : zone};
-    }
-    var obj = {
-        "type" : "method",
-        "name": "get",
-        "transactionid" : this.generateTransactionId(),
-        "data" : properties
-    };
-    this.send(obj, successCB, errorCB);
-}
-
-Vehicle.prototype.getHistory = function(event, startTime, endTime, successCB, errorCB)
-{
-    var obj = {
-        "type" : "method",
-        "name": "getHistory",
-        "transactionid" : this.generateTransactionId(),
-        "data" : [event, (startTime.getTime()/1000).toString(), (endTime.getTime()/1000).toString()]
-    };
-
-    this.send(obj, successCB, errorCB);
-
-}
-
-Vehicle.prototype.set = function(namelist, valuelist, zoneList, successCB, errorCB)
-{
-    if((namelist.length != valuelist.length)||(namelist.length <= 0))
-    {
-        return;
-    }
-
-    var obj = {
-        "type" : "method",
-        "name": "set",
-        "transactionid" : this.generateTransactionId(),
-        "data" : []
-    };
-    var list = [];
-    for(var i = 0; i < namelist.length; i++)
-    {
-        var val = {"property" : namelist[i], "value" : valuelist[i],"zone" : zoneList[i]};
-        list[list.length] = val;
-    }
-    obj.data = list;
-    this.send(obj, successCB, errorCB);
-}
-
-Vehicle.prototype.subscribe = function(namelist, zoneList, successCB, errorCB)
-{
-    var obj = {
-        "type" : "method",
-        "name": "subscribe",
-        "transactionid" : this.generateTransactionId(),
-        "data" : namelist,
-        "zone" : zoneList
-    };
-    this.send(obj, successCB, errorCB);
-}
-
-Vehicle.prototype.unsubscribe = function(namelist, zoneList, successCB, errorCB)
-{
-    var obj = {
-        "type" : "method",
-        "name": "unsubscribe",
-        "transactionid" : this.generateTransactionId(),
-        "data" : namelist,
-        "zone" : zoneList
-    };
-    this.send(obj, successCB, errorCB);
-}
-
-Vehicle.prototype.sendEvent = function(name, value)
-{
-    var evt = document.createEvent("Event");
-    evt.initEvent(name, true, true);
-    evt.name = name;
-    evt.value = value;
-    document.dispatchEvent(evt);
-    console.log(evt);
-}
-
-Vehicle.prototype.receive = function(msg)
-{
-    var self = this;
-    var event;
-    try {
-        event = JSON.parse(msg);
-    }
-    catch(e) {
-        self.iErrorCB("GARBAGE MESSAGE: "+msg);
-        return;
-    }
-
-    if((event === undefined)||(event.type === undefined)||
-       (event.name === undefined))
-    {
-        self.iErrorCB("BADLY FORMED MESSAGE: "+msg);
-        return;
-    }
-    else
-    {
-        if(event.type === "methodReply")
-        {
-            var calls = this.methodCalls;
-            for(var i = 0; i < calls.length; i++)
-            {
-                var call = calls[i];
-                if(call&&(!call.done)&&(call.transactionid === event.transactionid))
-                {
-                    call.finish();
-                    if(event.error !== undefined)
-                    {
-                        call.errorCB(event.error);
-                    }
-                    else if(event.data !== undefined && call.successCB !== undefined)
-                    {
-                        call.successCB(event.data);
-                    }
-                    return;
-                }
-            }
-        }
-        else if(event.type === "valuechanged")
-        {
-            self.sendEvent(event.name, event.data);
-        }
-    }
-}
-
-/*
-    // AMD / RequireJS
-    if (typeof define !== 'undefined' && define.amd) {
-        define([], function () {
-            return {
-                Vehicle: Vehicle
-            };
-        });
-    }
-    // Node.js
-    else if (typeof module !== 'undefined' && module.exports) {
-        module.exports = {
-                Vehicle: Vehicle
-            };
-    }
-    // included directly via <script> tag
-    else {
-        root.vehicle = {
-                Vehicle: Vehicle
-            };
-    }
-})();
-*/
diff --git a/plugins/websocketsink/websocketsink.cpp b/plugins/websocketsink/websocketsink.cpp
deleted file mode 100644 (file)
index 21093f5..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-       Copyright (C) 2012  Intel Corporation
-
-       This library is free software; you can redistribute it and/or
-       modify it under the terms of the GNU Lesser General Public
-       License as published by the Free Software Foundation; either
-       version 2.1 of the License, or (at your option) any later version.
-
-       This library is distributed in the hope that it will be useful,
-       but WITHOUT ANY WARRANTY; without even the implied warranty of
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-       Lesser General Public License for more details.
-
-       You should have received a copy of the GNU Lesser General Public
-       License along with this library; if not, write to the Free Software
-       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-
-#include "websocketsink.h"
-#include <glib.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sstream>
-#include "debugout.h"
-
-
-
-WebSocketSink::WebSocketSink(AbstractRoutingEngine* re,libwebsocket *wsi,string uuid,VehicleProperty::Property property,std::string ambdproperty) : AbstractSink(re,map<string, string> ())
-{
-       m_amdbproperty = ambdproperty;
-       m_uuid = uuid;
-       m_wsi = wsi;
-       m_property = property;
-       m_re = re;
-       re->subscribeToProperty(ambdproperty,this);
-}
-const string WebSocketSink::uuid()
-{
-       return m_uuid;
-}
-void WebSocketSink::propertyChanged(AbstractPropertyType *value)
-{
-       VehicleProperty::Property property = value->name;
-
-       stringstream s;
-       
-       //TODO: Dirty hack hardcoded stuff, jsut to make it work.
-       std::string tmpstr="";
-       if (m_property != property)
-       {
-               tmpstr = m_property;
-       }
-       else
-       {
-               tmpstr = property;
-       }
-       
-       s.precision(15);
-       
-       s << "{\"type\":\"valuechanged\",\"name\":\"" << tmpstr << "\",\"data\":";
-       s << "{ \"value\":\"" << value->toString() << "\",\"zone\":\""<<value->zone;
-       s << "\",\"timestamp\":\""<<value->timestamp<<"\",\"sequence\":\""<<value->sequence<<"\"},";
-       s << "\"transactionid\":\"" << m_uuid << "\"}";
-       
-       string replystr = s.str();
-       //printf("Reply: %s\n",replystr.c_str());
-       
-       DebugOut() << "Reply:" << replystr << "\n";
-
-       char *new_response = new char[LWS_SEND_BUFFER_PRE_PADDING + strlen(replystr.c_str()) + LWS_SEND_BUFFER_POST_PADDING];
-       new_response+=LWS_SEND_BUFFER_PRE_PADDING;
-       strcpy(new_response,replystr.c_str());
-       libwebsocket_write(m_wsi, (unsigned char*)new_response, strlen(new_response), LWS_WRITE_TEXT);
-       delete [] (char*)(new_response-LWS_SEND_BUFFER_PRE_PADDING);
-}
-WebSocketSink::~WebSocketSink()
-{
-       m_re->unsubscribeToProperty(m_amdbproperty,this);
-}
-void WebSocketSink::supportedChanged(PropertyList supportedProperties)
-{
-}
-PropertyList WebSocketSink::subscriptions()
-{
-       return PropertyList();
-} 
-
diff --git a/plugins/websocketsink/websocketsink.h b/plugins/websocketsink/websocketsink.h
deleted file mode 100644 (file)
index 94d4b69..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-       Copyright (C) 2012  Intel Corporation
-
-       This library is free software; you can redistribute it and/or
-       modify it under the terms of the GNU Lesser General Public
-       License as published by the Free Software Foundation; either
-       version 2.1 of the License, or (at your option) any later version.
-
-       This library is distributed in the hope that it will be useful,
-       but WITHOUT ANY WARRANTY; without even the implied warranty of
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-       Lesser General Public License for more details.
-
-       You should have received a copy of the GNU Lesser General Public
-       License along with this library; if not, write to the Free Software
-       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-
-#ifndef WEBSOCKETSINK_H
-#define WEBSOCKETSINK_H
-#include <glib.h>
-#include <abstractroutingengine.h>
-#include "abstractsink.h"
-#include <libwebsockets.h>
-class WebSocketSink : public AbstractSink
-{
-
-public:
-       WebSocketSink(AbstractRoutingEngine* re,libwebsocket *wsi,string uuid,VehicleProperty::Property property,std::string ambdproperty);
-       ~WebSocketSink();
-       const string uuid() ;
-       void propertyChanged(AbstractPropertyType *value);
-       void supportedChanged(PropertyList supportedProperties);
-       PropertyList subscriptions();
-       libwebsocket *socket() { return m_wsi; }
-private:
-       char *webSocketBuffer;
-       string m_amdbproperty;
-       AbstractRoutingEngine *m_re;
-       libwebsocket *m_wsi;
-       string m_uuid;
-       string m_property;
-};
-
-#endif // WEBSOCKETSINK_H
diff --git a/plugins/websocketsink/websocketsinkmanager.cpp b/plugins/websocketsink/websocketsinkmanager.cpp
deleted file mode 100644 (file)
index 94997f0..0000000
+++ /dev/null
@@ -1,769 +0,0 @@
-/*
-       Copyright (C) 2012  Intel Corporation
-
-       This library is free software; you can redistribute it and/or
-       modify it under the terms of the GNU Lesser General Public
-       License as published by the Free Software Foundation; either
-       version 2.1 of the License, or (at your option) any later version.
-
-       This library is distributed in the hope that it will be useful,
-       but WITHOUT ANY WARRANTY; without even the implied warranty of
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-       Lesser General Public License for more details.
-
-       You should have received a copy of the GNU Lesser General Public
-       License along with this library; if not, write to the Free Software
-       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-
-#include "websocketsinkmanager.h"
-#include "websocketsink.h"
-#include <sstream>
-#include <json/json.h>
-#include <json/json_object.h>
-#include <json/json_tokener.h>
-#include <listplusplus.h>
-#include <memory>
-
-#define __SMALLFILE__ std::string(__FILE__).substr(std::string(__FILE__).rfind("/")+1)
-
-//Global variables, these will be moved into the class
-struct pollfd pollfds[100];
-int count_pollfds = 0;
-libwebsocket_context *context;
-WebSocketSinkManager *sinkManager;
-static int websocket_callback(struct libwebsocket_context *context,struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, void *user,void *in, size_t len);
-bool gioPollingFunc(GIOChannel *source,GIOCondition condition,gpointer data);
-
-// libwebsocket_write helper function
-static int lwsWrite(struct libwebsocket *lws, const std::string& strToWrite)
-{
-       std::unique_ptr<char[]> buffer(new char[LWS_SEND_BUFFER_PRE_PADDING + strToWrite.length() + LWS_SEND_BUFFER_POST_PADDING]);
-
-       char *buf = buffer.get() + LWS_SEND_BUFFER_PRE_PADDING;
-       strcpy(buf, strToWrite.c_str());
-
-       //NOTE: delete[] on buffer is not needed since std::unique_ptr<char[]> is used
-       return libwebsocket_write(lws, (unsigned char*)buf, strToWrite.length(), LWS_WRITE_TEXT);
-}
-
-WebSocketSinkManager::WebSocketSinkManager(AbstractRoutingEngine* engine, map<string, string> config):AbstractSinkManager(engine, config)
-{
-       m_engine = engine;
-
-
-       //Create a listening socket on port 23000 on localhost.
-
-
-}
-void WebSocketSinkManager::init()
-{
-       //Protocol list for libwebsockets.
-       protocollist[0] = { "http-only", websocket_callback, 0 };
-       protocollist[1] = { NULL, NULL, 0 };
-
-
-       setConfiguration(configuration);
-}
-list< VehicleProperty::Property > WebSocketSinkManager::getSupportedProperties()
-{
-       return m_engine->supported();
-}
-void WebSocketSinkManager::setConfiguration(map<string, string> config)
-{
-//     //Config has been passed, let's start stuff up.
-       configuration = config;
-       struct lws_context_creation_info info;
-       memset(&info, 0, sizeof info);
-
-       //Default values
-       int port = 23000;
-       std::string interface = "lo";
-       std::string ssl_cert_path;
-       std::string ssl_key_path;
-       int options = 0;
-       bool ssl = false;
-       //Try to load config
-       for (map<string,string>::iterator i=configuration.begin();i!=configuration.end();i++)
-       {
-               //printf("Incoming setting: %s:%s\n",(*i).first.c_str(),(*i).second.c_str());
-               DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Incoming setting:" << (*i).first << ":" << (*i).second << "\n";
-               if ((*i).first == "interface")
-               {
-                       interface = (*i).second;
-               }
-               if ((*i).first == "port")
-               {
-                       port = boost::lexical_cast<int>((*i).second);
-               }
-               if ((*i).first == "cert")
-               {
-                       ssl_cert_path = (*i).second;
-               }
-               if ((*i).first == "key")
-               {
-                       ssl_key_path = (*i).second;
-               }
-               if ((*i).first == "ssl")
-               {
-                       if ((*i).second == "true")
-                       {
-                               ssl = true;
-                       }
-                       else
-                       {
-                               ssl = false;
-                       }
-               }
-       }
-       info.iface = interface.c_str();
-       info.protocols = protocollist;
-       info.extensions = libwebsocket_get_internal_extensions();
-       info.gid = -1;
-       info.uid = -1;
-       info.options = options;
-       info.port = port;
-       if (ssl)
-       {
-               info.ssl_cert_filepath = ssl_cert_path.c_str();
-               info.ssl_private_key_filepath = ssl_key_path.c_str();
-       }
-       context = libwebsocket_create_context(&info);
-       
-}
-
-void WebSocketSinkManager::addSingleShotSink(libwebsocket* socket, VehicleProperty::Property property, Zone::Type zone, string id)
-{
-       AsyncPropertyRequest request;
-       PropertyList foo = VehicleProperty::capabilities();
-       if (ListPlusPlus<VehicleProperty::Property>(&foo).contains(property))
-       {
-               request.property = property;
-       }
-       else
-       {
-               DebugOut(0)<<"websocketsink: Invalid property requested: "<<property;
-               return;
-       }
-
-       request.zoneFilter = zone;
-       request.completed = [socket,id,property](AsyncPropertyReply* reply)
-       {
-               DebugOut()<<"Got property: "<<reply->property.c_str()<<endl;
-               if(!reply->value){
-                       DebugOut()<<"Property value is null"<<endl;
-                       delete reply;
-                       return;
-               }
-
-               stringstream s;
-               s.precision(15);
-
-               s << "{\"type\":\"methodReply\",\"name\":\"get\",\"data\":{";
-               s << "\"property\":\"" << property << "\",\"zone\":\"" << reply->value->zone << "\",\"value\":\"" << reply->value->toString() << "\",\"timestamp\":\""<<reply->value->timestamp<<"\",";
-               s <<"\"sequence\": \""<<reply->value->sequence<<"\"}";
-               s << ",\"transactionid\":\"" << id << "\"}";
-
-               string replystr = s.str();
-               //printf("Reply: %s\n",replystr.c_str());
-               DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Reply:" << replystr << endl;
-
-               lwsWrite(socket, replystr);
-
-               delete reply;
-       };
-
-       AsyncPropertyReply* reply = routingEngine->getPropertyAsync(request);
-}
-
-void WebSocketSinkManager::addSingleShotRangedSink(libwebsocket* socket, PropertyList properties, double start, double end, double seqstart,double seqend, string id)
-{
-       AsyncRangePropertyRequest rangedRequest;
-
-       rangedRequest.timeBegin = start;
-       rangedRequest.timeEnd = end;
-       rangedRequest.sequenceBegin = seqstart;
-       rangedRequest.sequenceEnd = seqend;
-
-       rangedRequest.completed = [socket,id](AsyncRangePropertyReply* reply)
-       {
-               stringstream s;
-
-               stringstream data;
-               data.precision(15);
-               data<< "[";
-               std::list<AbstractPropertyType*> values = reply->values;
-               for(auto itr = values.begin(); itr != values.end(); itr++)
-               {
-                       if(itr != values.begin())
-                       {
-                               data<<",";
-                       }
-
-                       data << "{ \"value\" : " << "\"" << (*itr)->toString() << "\", \"timestamp\" : \"" << (*itr)->timestamp << "\", \"sequence\" : \""<<(*itr)->sequence<<"\" }";
-               }
-
-               data<<"]";
-
-               s << "{\"type\":\"methodReply\",\"name\":\"getRanged\",\"data\":"<<data.str()<<",\"transactionid\":\"" << id << "\"}";
-
-               string replystr = s.str();
-               //printf("Reply: %s\n",replystr.c_str());
-               DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Reply:" << replystr << "\n";
-
-               lwsWrite(socket, replystr);
-
-               delete reply;
-       };
-
-       AsyncRangePropertyReply* reply = routingEngine->getRangePropertyAsync(rangedRequest);
-}
-
-void WebSocketSinkManager::removeSink(libwebsocket* socket,VehicleProperty::Property property, string uuid)
-{
-       if (m_sinkMap.find(property) != m_sinkMap.end())
-       {
-               list<WebSocketSink*> sinks = m_sinkMap[property];
-
-               for(auto i = sinks.begin(); i != sinks.end(); i++)
-               {
-                       delete *i;
-               }
-
-               m_sinkMap.erase(property);
-
-               stringstream s;
-               s << "{\"type\":\"methodReply\",\"name\":\"unsubscribe\",\"data\":[\"" << property << "\"],\"transactionid\":\"" << uuid << "\"}";
-
-               string replystr = s.str();
-               //printf("Reply: %s\n",replystr.c_str());
-               DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Reply:" << replystr << "\n";
-
-               lwsWrite(socket, replystr);
-       }
-}
-void WebSocketSinkManager::setValue(libwebsocket* socket,VehicleProperty::Property property,string value,Zone::Type zone,string uuid)
-{
-       AbstractPropertyType* type = VehicleProperty::getPropertyTypeForPropertyNameValue(property,value);
-
-       AsyncSetPropertyRequest request;
-       request.property = property;
-       request.value = type;
-       request.zoneFilter = zone;
-       request.completed = [&](AsyncPropertyReply* reply)
-       {
-               ///TODO: do something here on !reply->success
-               stringstream s;
-               s << "{\"type\":\"methodReply\",\"name\":\"set\",\"data\":[{\"property\":\"" << property << "\",\"zone\":" << reply->zoneFilter
-                       << "}],\"transactionid\":\"" << uuid << "\"";
-               if(!reply->success)
-                       s << ",\"error\":\"method call failed\"";
-               s << "}";
-
-               string replystr = s.str();
-               DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Reply:" << replystr << "\n";
-
-               lwsWrite(socket, replystr);
-
-               delete reply;
-       };
-
-       m_engine->setProperty(request);
-       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "AbstractRoutingEngine::setProperty called with arguments:" << property << value << "\n";
-       delete type;
-
-}
-void WebSocketSinkManager::addSink(libwebsocket* socket, VehicleProperty::Property property,string uuid)
-{
-       stringstream s;
-
-       string tmpstr = "";
-       {
-               PropertyList foo = VehicleProperty::capabilities();
-               if (ListPlusPlus<VehicleProperty::Property>(&foo).contains(property))
-               {
-                       tmpstr = property;
-               }
-               else
-               {
-                       //Invalid property requested.
-                       return;
-               }
-
-       }
-       s << "{\"type\":\"methodReply\",\"name\":\"subscribe\",\"data\":[\"" << property << "\"],\"transactionid\":\"" << uuid << "\"}";
-
-       string replystr = s.str();
-       //printf("Reply: %s\n",replystr.c_str());
-       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Reply:" << replystr << "\n";
-
-       lwsWrite(socket, replystr);
-
-       WebSocketSink *sink = new WebSocketSink(m_engine,socket,uuid,property,tmpstr);
-       m_sinkMap[property].push_back(sink);
-}
-extern "C" AbstractSinkManager * create(AbstractRoutingEngine* routingengine, map<string, string> config)
-{
-       sinkManager = new WebSocketSinkManager(routingengine, config);
-       sinkManager->init();
-       return sinkManager;
-}
-void WebSocketSinkManager::disconnectAll(libwebsocket* socket)
-{
-       std::list<WebSocketSink*> toDeleteList;
-
-       for (auto i=m_sinkMap.begin(); i != m_sinkMap.end();i++)
-       {
-               std::list<WebSocketSink*> *sinks = & (*i).second;
-               for (auto sinkItr = sinks->begin(); sinkItr != sinks->end(); sinkItr++)
-               {
-                       if ((*sinkItr)->socket() == socket)
-                       {
-                               //This is the sink in question.
-                               WebSocketSink* sink = (*sinkItr);
-                               if(!ListPlusPlus<WebSocketSink*>(&toDeleteList).contains(sink))
-                               {
-                                       toDeleteList.push_back(sink);
-                               }
-
-                               sinks->erase(sinkItr);
-                               sinkItr = sinks->begin();
-                               DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Sink removed"<<endl;
-                       }
-               }
-       }
-
-       for(auto i=toDeleteList.begin();i!=toDeleteList.end();i++)
-       {
-               delete *i;
-       }
-}
-void WebSocketSinkManager::addPoll(int fd)
-{
-       GIOChannel *chan = g_io_channel_unix_new(fd);
-       guint sourceid = g_io_add_watch(chan, GIOCondition(G_IO_IN | G_IO_HUP | G_IO_ERR),(GIOFunc)gioPollingFunc,chan);
-       g_io_channel_set_close_on_unref(chan,true);
-       g_io_channel_unref(chan); //Pass ownership of the GIOChannel to the watch.
-       m_ioChannelMap[fd] = chan;
-       m_ioSourceMap[fd] = sourceid;
-}
-void WebSocketSinkManager::removePoll(int fd)
-{
-       g_io_channel_shutdown(m_ioChannelMap[fd],false,0);
-       //printf("Shutting down IO Channel\n");
-       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Shutting down IO Channel\n";
-       g_source_remove(m_ioSourceMap[fd]); //Since the watch owns the GIOChannel, this should unref it enough to dissapear.
-
-       //for (map<int,guint>::const_iterator i=m_ioSourceMap.cbegin();i!=m_ioSourceMap.cend();i++)
-       for (map<int,guint>::iterator i=m_ioSourceMap.begin();i!=m_ioSourceMap.end();i++)
-       {
-               if((*i).first == fd)
-               {
-                       //printf("Erasing source\n");
-                       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Erasing source\n";
-                       m_ioSourceMap.erase(i);
-                       i--;
-                       if (m_ioSourceMap.size() == 0)
-                       {
-                               break;
-                       }
-               }
-       }
-       //for (map<int,GIOChannel*>::const_iterator i=m_ioChannelMap.cbegin();i!=m_ioChannelMap.cend();i++)
-       for (map<int,GIOChannel*>::iterator i=m_ioChannelMap.begin();i!=m_ioChannelMap.end();i++)
-       {
-               if((*i).first == fd)
-               {
-                       //printf("Erasing channel\n");
-                       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Erasing channel\n";
-                       m_ioChannelMap.erase(i);
-                       i--;
-                       if (m_ioChannelMap.size() == 0)
-                       {
-                               break;
-                       }
-               }
-       }
-}
-
-static int websocket_callback(struct libwebsocket_context *context,struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason, void *user,void *in, size_t len)
-{
-       //printf("Switch: %i\n",reason);
-       DebugOut(5) << __SMALLFILE__ << ":" << __LINE__ << "websocket_callback:" << reason << endl;
-
-
-       switch (reason)
-       {
-               case LWS_CALLBACK_CLIENT_WRITEABLE:
-               {
-                       //Connection has been established.
-                       //printf("Connection established\n");
-                       break;
-               }
-               case LWS_CALLBACK_CLOSED:
-               {
-                       //Connection is closed, we need to remove all related sinks
-                       sinkManager->disconnectAll(wsi);
-                       /*g_io_
-                       GIOChannel *chan = g_io_channel_unix_new((int)(long)user);
-                       g_io_add_watch(chan,G_IO_IN,(GIOFunc)gioPollingFunc,0);
-                       g_io_add_watch(chan,G_IO_PRI,(GIOFunc)gioPollingFunc,0);
-                       pollfds[count_pollfds].fd = (int)(long)user;
-                       pollfds[count_pollfds].events = (int)len;
-//                     pollfds[count_pollfds++].revents = 0;*/
-                       break;
-               }
-               case LWS_CALLBACK_CLIENT_RECEIVE:
-               {
-                       //printf("Client writable\n");
-                       break;
-               }
-               case LWS_CALLBACK_SERVER_WRITEABLE:
-               {
-                       //printf("Server writable\n");
-                       break;
-               }
-
-               case LWS_CALLBACK_RECEIVE:
-               {
-                       //printf("Data Received: %s\n",(char*)in);
-                       //The lack of a break; here is intentional.
-               }
-               case LWS_CALLBACK_HTTP:
-               {
-                       //TODO: Verify that ALL requests get sent via LWS_CALLBACK_HTTP, so we can use that instead of LWS_CALLBACK_RECIEVE
-                       //TODO: Do we want exceptions, or just to return an invalid json reply? Probably an invalid json reply.
-                       DebugOut() << __SMALLFILE__ << ":" << __LINE__ << " Requested: " << (char*)in << "\n";
-
-                       std::string tempInput((char*)in);
-
-                       json_object *rootobject;
-                       json_tokener *tokener = json_tokener_new();
-                       enum json_tokener_error err;
-                       do
-                       {
-                               rootobject = json_tokener_parse_ex(tokener, tempInput.c_str(),len);
-                       } while ((err = json_tokener_get_error(tokener)) == json_tokener_continue);
-                       if (err != json_tokener_success)
-                       {
-                               fprintf(stderr, "Error: %s\n", json_tokener_error_desc(err));
-                               throw std::runtime_error("JSON Parsing error");
-                               // Handle errors, as appropriate for your application.
-                       }
-                       if(!rootobject)
-                       {
-                               DebugOut(0)<<"failed to parse json: "<<tempInput<<endl;
-                       }
-
-                       if (tokener->char_offset < len) // XXX shouldn't access internal fields
-                       {
-                               // Handle extra characters after parsed object as desired.
-                               // e.g. issue an error, parse another object from that point, etc...
-
-                       }
-                       // Success, use jobj here.
-                       json_object *typeobject = json_object_object_get(rootobject,"type");
-                       json_object *nameobject = json_object_object_get(rootobject,"name");
-                       json_object *transidobject = json_object_object_get(rootobject,"transactionid");
-                       
-                       string type = string(json_object_get_string(typeobject));
-                       string name = string(json_object_get_string(nameobject));
-                       string id;
-                       if (json_object_get_type(transidobject) == json_type_string)
-                       {
-                               id = string(json_object_get_string(transidobject));
-                       }
-                       else
-                       {
-                               stringstream strstr;
-                               strstr << json_object_get_int(transidobject);
-                               id = strstr.str();
-                       }
-                       json_object_put(typeobject);
-                       json_object_put(nameobject);
-                       json_object_put(transidobject);
-                       if (type == "method" && name == "getRanged")
-                       {
-                               json_object *dataobject = json_object_object_get(rootobject,"data");
-                               if (json_object_get_type(dataobject) == json_type_object)
-                               {
-                                       json_object *timeBeginObject = json_object_object_get(dataobject,"timeBegin");
-                                       json_object *timeEndObject = json_object_object_get(dataobject,"timeEnd");
-                                       json_object *sequenceBeginObject = json_object_object_get(dataobject,"sequenceBegin");
-                                       json_object *sequenceEndObject = json_object_object_get(dataobject,"sequenceEnd");
-                                       json_object *propertyObject = json_object_object_get(dataobject,"properties");
-                                       double timeBegin = boost::lexical_cast<double,std::string>(json_object_get_string(timeBeginObject));
-                                       double timeEnd = boost::lexical_cast<double,std::string>(json_object_get_string(timeEndObject));
-                                       double sequenceBegin = boost::lexical_cast<double,std::string>(json_object_get_string(sequenceBeginObject));
-                                       double sequenceEnd = boost::lexical_cast<double,std::string>(json_object_get_string(sequenceEndObject));
-
-                                       array_list *plist = json_object_get_array(propertyObject);
-
-                                       PropertyList propertyList;
-
-                                       for(int i=0; i < array_list_length(plist); i++)
-                                       {
-                                               json_object *prop = (json_object*)array_list_get_idx(plist,i);
-
-                                               std::string pstr = json_object_get_string(prop);
-
-                                               propertyList.push_back(pstr);
-                                       }
-
-                                       json_object_put(timeBeginObject);
-                                       json_object_put(timeEndObject);
-                                       json_object_put(sequenceBeginObject);
-                                       json_object_put(sequenceEndObject);
-                                       json_object_put(propertyObject);
-
-                                       if ((timeBegin < 0 && timeEnd > 0) || (timeBegin > 0 && timeEnd < 0))
-                                       {
-                                               DebugOut(DebugOut::Warning)<<"Invalid time begin/end pair"<<endl;
-                                       }
-                                       else if ((sequenceBegin < 0 && sequenceEnd > 0) || (sequenceBegin > 0 && sequenceEnd < 0))
-                                       {
-                                               DebugOut(DebugOut::Warning)<<"Invalid sequence begin/end pair"<<endl;
-                                       }
-                                       else
-                                       {
-                                               sinkManager->addSingleShotRangedSink(wsi,propertyList,timeBegin,timeEnd,sequenceBegin,sequenceEnd,id);
-                                       }
-                               }
-                               json_object_put(dataobject);
-                       }
-                       else
-                       {
-
-                               vector<string> data;
-                               list<string> key;
-                               list<string> value;
-                               list<Zone::Type> zone;
-                               json_object *dataobject = json_object_object_get(rootobject,"data");
-                               if (json_object_get_type(dataobject) == json_type_array)
-                               {
-                                       array_list *arraylist = json_object_get_array(dataobject);
-                                       for (int i=0;i<array_list_length(arraylist);i++)
-                                       {
-                                               json_object *arrayobject = (json_object*)array_list_get_idx(arraylist,i);
-                                               if (json_object_get_type(arrayobject) == json_type_object)
-                                               {
-                                                       json_object *propobject = json_object_object_get(arrayobject,"property");
-                                                       json_object *valueobject = json_object_object_get(arrayobject,"value");
-                                                       json_object *zoneobject = json_object_object_get(arrayobject,"zone");
-                                                       string keystr = string(propobject ? json_object_get_string(propobject) : "");
-                                                       string valuestr = string(valueobject ? json_object_get_string(valueobject): "");
-                                                       key.push_back(keystr);
-                                                       value.push_back(valuestr);
-                                                       Zone::Type z(Zone::None);
-                                                       if(zoneobject){
-                                                               try {
-                                                                       z = static_cast<Zone::Type>(boost::lexical_cast<int,std::string>(json_object_get_string(zoneobject)));
-                                                               } catch (...) { }
-                                                       }
-                                                       zone.push_back(z);
-                                                       json_object_put(propobject);
-                                                       json_object_put(valueobject);
-                                                       json_object_put(zoneobject);
-                                               }
-                                               else if (json_object_get_type(arrayobject) == json_type_string)
-                                               {
-                                                       string path = string(json_object_get_string(arrayobject));
-                                                       data.push_back(path);
-                                               }
-                                       }
-                                       //array_list_free(arraylist);
-                               }
-                               else
-                               {
-                                       string path = json_object_get_string(dataobject);
-                                       if (path != "")
-                                       {
-                                               data.push_back(path);
-                                       }
-                               }
-                               json_object_put(dataobject);
-                               if (type == "method")
-                               {
-                                       if (name == "get")
-                                       {
-                                               if (data.size() > 0)
-                                               {
-                                                       //GetProperty is going to be a singleshot sink.
-                                                       sinkManager->addSingleShotSink(wsi,data.front(),Zone::None,id);
-                                               }
-                                               else if (key.size() > 0 && key.size() == zone.size())
-                                               {
-                                                       //GetProperty is going to be a singleshot sink.
-                                                       sinkManager->addSingleShotSink(wsi,key.front(),zone.front(),id);
-                                               }
-                                               else
-                                               {
-                                                       DebugOut() << __SMALLFILE__ << ":" << __LINE__ << " \"get\" method called with no data! Transaction ID:" << id << "\n";
-                                               }
-                                       }
-                                       else if (name == "set")
-                                       {
-                                               if (data.size() > 0)
-                                               {
-                                                       //Should not happen
-                                               }
-                                               else if (value.size() > 0)
-                                               {
-                                                       if (key.size() != value.size())
-                                                       {
-                                                               DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "\"set\" method called with an invalid key value pair count\n";
-                                                       }
-                                                       else
-                                                       {
-                                                               list<string>::iterator d = value.begin();
-                                                               list<Zone::Type>::iterator z = zone.begin();
-                                                               for (list<string>::iterator i=key.begin();i!=key.end();++i)
-                                                               {
-                                                                       DebugOut() << __SMALLFILE__ << ":" << __LINE__ <<
-                                                                       "websocketsinkmanager setting " << (*i) << "to " << (*d) << "in zone " << (*z) << "\n";
-                                                                       //(*i);
-                                                                       sinkManager->setValue(wsi,(*i),(*d),(*z), id);
-                                                                       //(*d);
-                                                                       ++d;
-                                                                       ++z;
-                                                               }
-
-                                                       }
-                                               }
-                                       }
-                                       else if (name == "subscribe")
-                                       {
-                                               //Websocket wants to subscribe to an event, data.front();
-                                               for (auto i=data.begin();i!=data.end();i++)
-                                               {
-                                                       sinkManager->addSink(wsi,(*i),id);
-                                               }
-                                       }
-                                       else if (name == "unsubscribe")
-                                       {
-                                               //Websocket wants to unsubscribe to an event, data.front();
-                                               for (auto i=data.begin();i!=data.end();i++)
-                                               {
-                                                       sinkManager->removeSink(wsi,(*i),id);
-                                               }
-                                       }
-                                       else if (name == "getSupportedEventTypes")
-                                       {
-                                               //If data.front() dosen't contain a property name, return a list of properties supported.
-                                               //if it does, then return the event types that particular property supports.
-                                               string typessupported = "";
-                                               if (data.size() == 0)
-                                               {
-                                                       //Send what properties we support
-                                                       PropertyList foo = sinkManager->getSupportedProperties();
-                                                       PropertyList::const_iterator i=foo.cbegin();
-                                                       while (i != foo.cend())
-                                                       {
-                                                               if(i==foo.cbegin())
-                                                                       typessupported.append("\"").append((*i)).append("\"");
-                                                               else
-                                                                       typessupported.append(",\"").append((*i)).append("\"");
-                                                               i++;
-                                                       }
-                                               }
-                                               else
-                                               {
-                                                       //Send what events a particular property supports
-                                                       PropertyList foo = sinkManager->getSupportedProperties();
-                                                       if (ListPlusPlus<VehicleProperty::Property>(&foo).contains(data.front()))
-                                                       {
-                                                               //sinkManager->addSingleShotSink(wsi,data.front(),id);
-                                                               typessupported = "\"get\",\"subscribe\",\"unsubscribe\",\"getSupportedEventTypes\"";
-                                                       }
-                                               }
-                                               stringstream s;
-                                               string s2;
-                                               s << "{\"type\":\"methodReply\",\"name\":\"getSupportedEventTypes\",\"data\":[" << typessupported << "],\"transactionid\":\"" << id << "\"}";
-                                               string replystr = s.str();
-                                               DebugOut() << __SMALLFILE__ << ":" << __LINE__ << " JSON Reply: " << replystr << "\n";
-                                               //printf("Reply: %s\n",replystr.c_str());
-                                               lwsWrite(wsi, replystr);
-                                       }
-                                       else
-                                       {
-                                               DebugOut(0)<<"Unknown method called."<<endl;
-                                       }
-                               }
-                       }
-
-                       
-
-                       
-                       break;
-               }
-               case LWS_CALLBACK_ADD_POLL_FD:
-               {
-                       //printf("Adding poll %i\n",sinkManager);
-                       DebugOut(5) << __SMALLFILE__ <<":"<< __LINE__ << "Adding poll" << endl;
-                       if (sinkManager != 0)
-                       {
-                               //sinkManager->addPoll((int)(long)user);
-                               sinkManager->addPoll(libwebsocket_get_socket_fd(wsi));
-                       }
-                       else
-                       {
-                               DebugOut(5) << "Error, invalid sink manager!!" << endl;
-                       }
-                       break;
-               }
-               case LWS_CALLBACK_DEL_POLL_FD:
-               {
-                       sinkManager->removePoll(libwebsocket_get_socket_fd(wsi));
-                       break;
-               }
-               case LWS_CALLBACK_SET_MODE_POLL_FD:
-               {
-                       //Set the poll mode
-                       break;
-               }
-               case LWS_CALLBACK_CLEAR_MODE_POLL_FD:
-               {
-                       //Don't handle this yet.
-                       break;
-               }
-               default:
-               {
-                       //printf("Unhandled callback: %i\n",reason);
-                       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Unhandled callback:" << reason << "\n";
-                       break;
-               }
-       }
-       return 0; 
-}
-
-bool gioPollingFunc(GIOChannel *source, GIOCondition condition, gpointer data)
-{
-       DebugOut(5) << "Polling..." << condition << endl;
-
-       if(condition & G_IO_ERR)
-       {
-               DebugOut(0)<< __SMALLFILE__ <<":"<< __LINE__ <<" websocketsink polling error."<<endl;
-       }
-
-       if (condition & G_IO_HUP)
-       {
-               //Hang up. Returning false closes out the GIOChannel.
-               //printf("Callback on G_IO_HUP\n");
-               DebugOut(0)<<"socket hangup event..."<<endl;
-               return false;
-       }
-
-       //This is the polling function. If it return false, glib will stop polling this FD.
-       //printf("Polling...%i\n",condition);
-       
-       lws_tokens token;
-       struct pollfd pollstruct;
-       int newfd = g_io_channel_unix_get_fd(source);
-       pollstruct.fd = newfd;
-       pollstruct.events = condition;
-       pollstruct.revents = condition;
-       libwebsocket_service_fd(context,&pollstruct);
-
-       return true;
-}
diff --git a/plugins/websocketsink/websocketsinkmanager.h b/plugins/websocketsink/websocketsinkmanager.h
deleted file mode 100644 (file)
index f7178bd..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-       Copyright (C) 2012  Intel Corporation
-
-       This library is free software; you can redistribute it and/or
-       modify it under the terms of the GNU Lesser General Public
-       License as published by the Free Software Foundation; either
-       version 2.1 of the License, or (at your option) any later version.
-
-       This library is distributed in the hope that it will be useful,
-       but WITHOUT ANY WARRANTY; without even the implied warranty of
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-       Lesser General Public License for more details.
-
-       You should have received a copy of the GNU Lesser General Public
-       License along with this library; if not, write to the Free Software
-       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-#ifndef WEBSOCKETSINKMANAGER_H
-#define WEBSOCKETSINKMANAGER_H
-
-#include <abstractroutingengine.h>
-#include <abstractsink.h>
-#include "websocketsink.h"
-#include <gio/gio.h>
-#include <map>
-#include <libwebsockets.h>
-#include "debugout.h"
-#include <stdexcept>
-#include "sys/types.h"
-#include <stdlib.h>
-
-class WebSocketSinkManager: public AbstractSinkManager
-{
-public:
-       WebSocketSinkManager(AbstractRoutingEngine* engine, map<string, string> config);
-       void addSingleShotSink(libwebsocket* socket, VehicleProperty::Property property, Zone::Type zone, string id);
-       void addSingleShotRangedSink(libwebsocket* socket, PropertyList properties,double start, double end, double seqstart,double seqend, string id);
-       void addSink(libwebsocket* socket, VehicleProperty::Property property,string uuid);
-       void disconnectAll(libwebsocket* socket);
-       void removeSink(libwebsocket* socket,VehicleProperty::Property property,string uuid);
-       void addPoll(int fd);
-       void removePoll(int fd);
-       void init();
-       map<std::string, list<WebSocketSink*> > m_sinkMap;
-       void setConfiguration(map<string, string> config);
-       void setValue(libwebsocket* socket,VehicleProperty::Property property,string value, Zone::Type zone, string uuid);
-       list<VehicleProperty::Property> getSupportedProperties();
-private:
-       map<int,GIOChannel*> m_ioChannelMap;
-       map<int,guint> m_ioSourceMap;
-       AbstractRoutingEngine *m_engine;
-       struct libwebsocket_protocols protocollist[2];
-};
-
-#endif // WEBSOCKETSINKMANAGER_H
diff --git a/plugins/websocketsourceplugin/CMakeLists.txt b/plugins/websocketsourceplugin/CMakeLists.txt
deleted file mode 100644 (file)
index dff8dec..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-if(websocketold_plugin)
-
-include(CheckIncludeFiles)
-include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs})
-
-pkg_check_modules(websockets REQUIRED libwebsockets)
-
-set(websocketsourceplugin_headers websocketsource.h)
-set(websocketsourceplugin_sources websocketsource.cpp)
-add_library(websocketsourceplugin MODULE ${websocketsourceplugin_sources})
-set_target_properties(websocketsourceplugin PROPERTIES PREFIX "")
-target_link_libraries(websocketsourceplugin amb ${websockets_LIBRARIES} -L${CMAKE_CURRENT_BINARY_DIR}/lib ${link_libraries})
-
-install(TARGETS websocketsourceplugin LIBRARY DESTINATION ${PLUGIN_INSTALL_PATH})
-
-endif(websocketold_plugin)
diff --git a/plugins/websocketsourceplugin/websocketsource.cpp b/plugins/websocketsourceplugin/websocketsource.cpp
deleted file mode 100644 (file)
index 371ee0d..0000000
+++ /dev/null
@@ -1,638 +0,0 @@
-/*
-       Copyright (C) 2012  Intel Corporation
-
-       This library is free software; you can redistribute it and/or
-       modify it under the terms of the GNU Lesser General Public
-       License as published by the Free Software Foundation; either
-       version 2.1 of the License, or (at your option) any later version.
-
-       This library is distributed in the hope that it will be useful,
-       but WITHOUT ANY WARRANTY; without even the implied warranty of
-       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-       Lesser General Public License for more details.
-
-       You should have received a copy of the GNU Lesser General Public
-       License along with this library; if not, write to the Free Software
-       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-
-#include "websocketsource.h"
-#include <iostream>
-#include <boost/assert.hpp>
-#include <boost/lexical_cast.hpp>
-#include <glib.h>
-#include <sstream>
-#include <listplusplus.h>
-#include <timestamp.h>
-#include "uuidhelper.h"
-
-#include "debugout.h"
-#define __SMALLFILE__ std::string(__FILE__).substr(std::string(__FILE__).rfind("/")+1)
-libwebsocket_context *context = NULL;
-WebSocketSource *source;
-AbstractRoutingEngine *m_re;
-
-double oldTimestamp=0;
-double totalTime=0;
-double numUpdates=0;
-double averageLatency=0;
-
-static int callback_http_only(libwebsocket_context *context,struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason,void *user, void *in, size_t len);
-static struct libwebsocket_protocols protocols[] = {
-       {
-               "http-only",
-               callback_http_only,
-               0,
-               128,
-       },
-       {  /* end of list */
-               NULL,
-               NULL,
-               0,
-               0
-       }
-};
-
-//Called when a client connects, subscribes, or unsubscribes.
-void WebSocketSource::checkSubscriptions()
-{
-       PropertyList notSupportedList;
-       while (queuedRequests.size() > 0)
-       {
-               VehicleProperty::Property prop = queuedRequests.front();
-               queuedRequests.pop_front();
-               if (ListPlusPlus<VehicleProperty::Property>(&activeRequests).contains(prop))
-               {
-                       return;
-               }
-               activeRequests.push_back(prop);
-               stringstream s;
-               ///TODO: fix transid here:
-               s << "{\"type\":\"method\",\"name\":\"subscribe\",\"data\":[\"" << prop << "\"],\"transactionid\":\"" << "d293f670-f0b3-11e1-aff1-0800200c9a66" << "\"}";
-
-               string replystr = s.str();
-               DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Reply:" << replystr << "\n";
-               //printf("Reply: %s\n",replystr.c_str());
-
-               char *new_response = new char[LWS_SEND_BUFFER_PRE_PADDING + strlen(replystr.c_str()) + LWS_SEND_BUFFER_POST_PADDING];
-               new_response+=LWS_SEND_BUFFER_PRE_PADDING;
-               strcpy(new_response,replystr.c_str());
-               if(clientsocket)
-                       libwebsocket_write(clientsocket, (unsigned char*)new_response, strlen(new_response), LWS_WRITE_TEXT);
-               delete (char*)(new_response-LWS_SEND_BUFFER_PRE_PADDING);
-       }
-}
-void WebSocketSource::setConfiguration(map<string, string> config)
-{
-       //printf("WebSocketSource::setConfiguration has been called\n");
-       std::string ip;
-       int port;
-       configuration = config;
-       for (map<string,string>::iterator i=configuration.begin();i!=configuration.end();i++)
-       {
-               DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Incoming setting for WebSocketSource:" << (*i).first << ":" << (*i).second << "\n";
-               //printf("Incoming setting: %s:%s\n",(*i).first.c_str(),(*i).second.c_str());
-               if ((*i).first == "ip")
-               {
-                       ip = (*i).second;
-               }
-               if ((*i).first == "port")
-               {
-                       port = boost::lexical_cast<int>((*i).second);
-               }
-               if ((*i).first == "ssl")
-               {
-                       if ((*i).second == "true")
-                       {
-                               m_sslEnabled = true;
-                       }
-                       else
-                       {
-                               m_sslEnabled = false;
-                       }       
-               }
-       }
-       //printf("Connecting to websocket server at %s port %i\n",ip.c_str(),port);
-       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Connecting to websocket server at" << ip << ":" << port << "\n";
-       int sslval = 0;
-       if (m_sslEnabled)
-       {
-               DebugOut(5) << "SSL ENABLED" << endl;
-               sslval = 2;
-       }
-
-       clientsocket = libwebsocket_client_connect(context, ip.c_str(), port, sslval,"/", "localhost", "websocket",protocols[0].name, -1);
-       
-
-}
-
-PropertyInfo WebSocketSource::getPropertyInfo(VehicleProperty::Property property)
-{
-       return PropertyInfo::invalid();
-}
-
-bool gioPollingFunc(GIOChannel *source, GIOCondition condition, gpointer data)
-{
-       //This is the polling function. If it return false, glib will stop polling this FD.
-
-       oldTimestamp = amb::currentTime();
-
-       struct pollfd pollstruct;
-       int newfd = g_io_channel_unix_get_fd(source);
-       pollstruct.fd = newfd;
-       pollstruct.events = condition;
-       pollstruct.revents = condition;
-       libwebsocket_service_fd(context,&pollstruct);
-       if (condition & G_IO_HUP)
-       {
-               //Hang up. Returning false closes out the GIOChannel.
-               //printf("Callback on G_IO_HUP\n");
-               return false;
-       }
-       if (condition & G_IO_IN)
-       {
-
-       }
-       DebugOut() << "gioPollingFunc" << condition << endl;
-
-       return true;
-}
-
-static int checkTimeouts(gpointer data)
-{
-       WebSocketSource *src = (WebSocketSource*)data;
-       for (auto i=src->uuidTimeoutMap.begin();i!= src->uuidTimeoutMap.end();i++)
-       {
-               if (src->uuidRangedReplyMap.find((*i).first) != src->uuidRangedReplyMap.end())
-               {
-                       //A source exists!
-                       if (amb::currentTime() > (*i).second)
-                       {
-                               //We've reached timeout
-                               DebugOut() << "Timeout reached for request ID:" << (*i).first << "\n";
-                               src->uuidRangedReplyMap[(*i).first]->success = false;
-                               src->uuidRangedReplyMap[(*i).first]->completed(src->uuidRangedReplyMap[(*i).first]);
-                               src->uuidRangedReplyMap.erase((*i).first);
-                               src->uuidTimeoutMap.erase((*i).first);
-                               i--;
-
-                               if (src->uuidTimeoutMap.size() == 0)
-                               {
-                                       return 0;
-                               }
-
-                       }
-                       else
-                       {
-                               //No timeout yet, keep waiting.
-                       }
-               }
-               else
-               {
-                       //Reply has already come back, ignore and erase from list.
-                       src->uuidTimeoutMap.erase((*i).first);
-                       i--;
-
-                       if (src->uuidTimeoutMap.size() == 0)
-                       {
-                               return 0;
-                       }
-               }
-
-       }
-       return 0;
-}
-
-static int callback_http_only(libwebsocket_context *context,struct libwebsocket *wsi,enum libwebsocket_callback_reasons reason,void *user, void *in, size_t len)
-{
-       unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 4096 + LWS_SEND_BUFFER_POST_PADDING];
-       int l;
-       DebugOut() << __SMALLFILE__ << ":" << __LINE__ << reason << "callback_http_only" << endl;
-       switch (reason)
-       {
-               case LWS_CALLBACK_CLOSED:
-                       //fprintf(stderr, "mirror: LWS_CALLBACK_CLOSED\n");
-                       //wsi_mirror = NULL;
-                       //printf("Connection closed!\n");
-                       break;
-
-               //case LWS_CALLBACK_PROTOCOL_INIT:
-               case LWS_CALLBACK_CLIENT_ESTABLISHED:
-               {
-                       //This happens when a client initally connects. We need to request the support event types.
-                       source->clientConnected = true;
-                       source->checkSubscriptions();
-                       //printf("Incoming connection!\n");
-                       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Incoming connection" << endl;
-                       stringstream s;
-                       s << "{\"type\":\"method\",\"name\":\"getSupportedEventTypes\",\"data\":[],\"transactionid\":\"" << "d293f670-f0b3-11e1-aff1-0800200c9a66" << "\"}";
-
-                       string replystr = s.str();
-                       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Reply:" << replystr << "\n";
-                       char *new_response = new char[LWS_SEND_BUFFER_PRE_PADDING + strlen(replystr.c_str()) + LWS_SEND_BUFFER_POST_PADDING];
-                       new_response+=LWS_SEND_BUFFER_PRE_PADDING;
-                       strcpy(new_response,replystr.c_str());
-                       libwebsocket_write(wsi, (unsigned char*)(new_response), strlen(new_response), LWS_WRITE_TEXT);
-                       delete (char*)(new_response-LWS_SEND_BUFFER_PRE_PADDING);
-
-                       break;
-               }
-               case LWS_CALLBACK_CLIENT_RECEIVE:
-               {
-                       double prejsonparsetime = (amb::currentTime() - oldTimestamp)*1000;
-
-                       DebugOut(2)<<"websocket source pre-json parse time: "<<prejsonparsetime<<endl;
-
-                       json_object *rootobject;
-                       json_tokener *tokener = json_tokener_new();
-                       enum json_tokener_error err;
-                       do
-                       {
-                               rootobject = json_tokener_parse_ex(tokener, (char*)in,len);
-                       } while ((err = json_tokener_get_error(tokener)) == json_tokener_continue);
-                       if (err != json_tokener_success)
-                       {
-                               fprintf(stderr, "Error: %s\n", json_tokener_error_desc(err));
-                               // Handle errors, as appropriate for your application.
-                       }
-                       if (tokener->char_offset < len) // XXX shouldn't access internal fields
-                       {
-                               // Handle extra characters after parsed object as desired.
-                               // e.g. issue an error, parse another object from that point, etc...
-                       }
-                       //Incoming JSON reqest.
-                       
-
-                       DebugOut(5)<<"source received: "<<string((char*)in)<<endl;
-                       
-                       json_object *typeobject= json_object_object_get(rootobject,"type");
-                       json_object *nameobject= json_object_object_get(rootobject,"name");
-                       json_object *transidobject= json_object_object_get(rootobject,"transactionid");
-
-
-                       string type = string(json_object_get_string(typeobject));
-                       string name = string(json_object_get_string(nameobject));
-                       
-                       string id;
-                       
-                       if (json_object_get_type(transidobject) == json_type_string)
-                       {
-                               id = json_object_get_string(transidobject);
-                       }
-                       else
-                       {
-                               stringstream strstr;
-                               strstr << json_object_get_int(transidobject);
-                               id = strstr.str();
-                       }
-                       
-                       list<pair<string,string> > pairdata;
-                       if (type == "valuechanged")
-                       {
-                               json_object *dataobject = json_object_object_get(rootobject,"data");
-                               
-                               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));
-                               string sequence = string(json_object_get_string(sequenceobject));
-                               //printf("Value changed: %s, %s\n",name.c_str(),data.front().c_str());
-                               DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Value changed:" << name << value << endl;
-                               //Name should be a valid property
-                               //      routingEngine->updateProperty(VehicleProperty::VehicleSpeed, velocity);
-                               //data.front()
-                               try
-                               {
-                                       AbstractPropertyType* type = VehicleProperty::getPropertyTypeForPropertyNameValue(name,value);
-                                       type->timestamp = boost::lexical_cast<double,std::string>(timestamp);
-                                       type->sequence = boost::lexical_cast<double,std::string>(sequence);
-                                       m_re->updateProperty(type, source->uuid());
-                                       double currenttime = amb::currentTime();
-
-                                       /** This is now the latency between when something is available to read on the socket, until
-                                        *  a property is about to be updated in AMB.  This includes libwebsockets parsing and the
-                                        *  JSON parsing in this section.
-                                        */
-                                       
-                                       DebugOut(2)<<"websocket parse latency: "<<(currenttime - oldTimestamp)*1000<<"ms"<<endl;
-                                       DebugOut(2)<<"websocket network + parse latency: "<<(currenttime - type->timestamp)*1000<<"ms"<<endl;
-                                       totalTime += (currenttime - oldTimestamp)*1000;
-                                       numUpdates ++;
-                                       averageLatency = totalTime / numUpdates;
-
-                                       DebugOut(2)<<"Average parse latency: "<<averageLatency<<endl;
-
-                                       delete type;
-                               }
-                               catch (exception ex)
-                               {
-                                       //printf("Exception %s\n",ex.what());
-                                       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Exception:" << ex.what() << "\n";
-                               }
-                               json_object_put(valueobject);
-                               json_object_put(timestampobject);
-                               json_object_put(sequenceobject);
-                               json_object_put(dataobject);
-                               //printf("Done\n");
-                               /*if (name == "get")
-                               {
-                                       if (data.size() > 0)
-                                       {
-                                       }
-                               }*/
-                       }
-                       else if (type == "methodReply")
-                       {
-                               json_object *dataobject = json_object_object_get(rootobject,"data");
-                               if (name == "getSupportedEventTypes")
-                               {
-                                       //printf("Got supported events!\n");
-                                       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Got getSupportedEventTypes request"<<endl;
-                                       PropertyList props;
-                                       if (json_object_get_type(dataobject) == json_type_array)
-                                       {
-                                               array_list *dataarray = json_object_get_array(dataobject);
-                                               for (int i=0;i<array_list_length(dataarray);i++)
-                                               {
-                                                       json_object *arrayobj = (json_object*)array_list_get_idx(dataarray,i);
-                                                       props.push_back(string(json_object_get_string(arrayobj)));
-                                               }
-                                               //array_list_free(dataarray);
-                                       }
-                                       else
-                                       {
-                                               props.push_back(string(json_object_get_string(dataobject)));
-                                       }
-                                       source->setSupported(props);
-                                       //m_re->updateSupported(m_supportedProperties,PropertyList());
-                               }
-                               else if (name == "getRanged")
-                               {
-                                       std::list<AbstractPropertyType*> propertylist;
-                                       array_list *dataarray = json_object_get_array(dataobject);
-                                       for (int i=0;i<array_list_length(dataarray);i++)
-                                       {
-                                               json_object *arrayobj = (json_object*)array_list_get_idx(dataarray,i);
-                                               json_object *keyobject = json_object_object_get(arrayobj,"name");
-                                               json_object *valueobject = json_object_object_get(arrayobj,"value");
-                                               json_object *timestampobject = json_object_object_get(arrayobj,"timestamp");
-                                               json_object *sequenceobject = json_object_object_get(arrayobj,"sequence");
-                                               std::string name = json_object_get_string(keyobject);
-                                               std::string value = json_object_get_string(valueobject);
-                                               std::string timestamp = json_object_get_string(timestampobject);
-                                               std::string sequence = json_object_get_string(sequenceobject);
-
-                                               ///TODO: we might only have to free the dataobject at the end instead of this:
-
-                                               json_object_put(keyobject);
-                                               json_object_put(valueobject);
-                                               json_object_put(timestampobject);
-                                               json_object_put(sequenceobject);
-                                                       
-                                               AbstractPropertyType* type = VehicleProperty::getPropertyTypeForPropertyNameValue(name,value);
-                                               propertylist.push_back(type);
-                                       }
-                                       //array_list_free(dataarray);
-                                       if (source->uuidRangedReplyMap.find(id) != source->uuidRangedReplyMap.end())
-                                       {
-                                               source->uuidRangedReplyMap[id]->values = propertylist;
-                                               source->uuidRangedReplyMap[id]->success = true;
-                                               source->uuidRangedReplyMap[id]->completed(source->uuidRangedReplyMap[id]);
-                                               source->uuidRangedReplyMap.erase(id);
-                                       }
-                                       else
-                                       {
-                                               DebugOut() << "getRanged methodReply has been recieved, without a request being in!. This is likely due to a request coming in after the timeout has elapsed.\n";
-                                       }
-                               }
-                               else if (name == "get")
-                               {
-                                       
-                                       DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "Got \"GET\" event:" << pairdata.size()<<endl;
-                                       if (source->uuidReplyMap.find(id) != source->uuidReplyMap.end())
-                                       {
-                                               json_object *propertyobject = json_object_object_get(dataobject,"property");
-                                               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");
-                                               std::string property = json_object_get_string(propertyobject);
-                                               std::string value = json_object_get_string(valueobject);
-                                               std::string timestamp = json_object_get_string(timestampobject);
-                                               std::string sequence = json_object_get_string(sequenceobject);
-                                               json_object_put(propertyobject);
-                                               json_object_put(valueobject);
-                                               json_object_put(timestampobject);
-                                               json_object_put(sequenceobject);
-                                               
-                                               AbstractPropertyType* v = VehicleProperty::getPropertyTypeForPropertyNameValue(property,value);
-                                               v->timestamp = boost::lexical_cast<double,std::string>(timestamp);
-                                               v->sequence = boost::lexical_cast<double,std::string>(sequence);
-                                               if (source->uuidReplyMap.find(id) != source->uuidReplyMap.end())
-                                               {
-                                                       source->uuidReplyMap[id]->value = v;
-                                                       source->uuidReplyMap[id]->success = true;
-                                                       source->uuidReplyMap[id]->completed(source->uuidReplyMap[id]);
-                                                       source->uuidReplyMap.erase(id);
-
-                                               }
-                                               else
-                                               {
-                                                       DebugOut() << "get methodReply has been recieved, without a request being in!. This is likely due to a request coming in after the timeout has elapsed.\n";
-                                               }
-
-                                               delete v;
-                                       }
-                                       else
-                                       {
-                                               DebugOut() << __SMALLFILE__ << ":" << __LINE__ << "GET Method Reply INVALID! Multiple properties detected, only single are supported!!!" << "\n";
-                                       }
-                                       
-                                       //data will contain a property/value map.
-                               }
-                               json_object_put(dataobject);
-                       }
-                       json_object_put(rootobject);
-
-                       break;
-
-               }
-               case LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED:
-               {
-                       //printf("Requested extension: %s\n",(char*)in);
-                       return 0;
-                       break;
-               }
-               case LWS_CALLBACK_ADD_POLL_FD:
-               {
-                       DebugOut(5) << __SMALLFILE__ << ":" << __LINE__ << "Adding poll for websocket IO channel" << endl;
-                       //Add a FD to the poll list.
-                       GIOChannel *chan = g_io_channel_unix_new(libwebsocket_get_socket_fd(wsi));
-
-                       /// TODO: I changed this to be more consistent with the websocket sink end. it may not be correct. TEST
-
-                       g_io_add_watch(chan,GIOCondition(G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP),(GIOFunc)gioPollingFunc,0);
-                       g_io_channel_set_close_on_unref(chan,true);
-                       g_io_channel_unref(chan); //Pass ownership of the GIOChannel to the watch.
-                       
-                       break;
-               }
-               return 0;
-       }
-}
-void WebSocketSource::setSupported(PropertyList list)
-{
-       DebugOut() <<__SMALLFILE__ << ":" << __LINE__ <<"SET SUPPORTED"<<endl;
-       m_supportedProperties = list;
-       m_re->updateSupported(list,PropertyList(),this);
-}
-
-WebSocketSource::WebSocketSource(AbstractRoutingEngine *re, map<string, string> config) : AbstractSource(re, config)
-{
-       m_sslEnabled = false;
-       clientConnected = false;
-       source = this;
-       m_re = re;
-       struct lws_context_creation_info info;
-       memset(&info, 0, sizeof info);
-       info.protocols = protocols;
-       info.extensions = libwebsocket_get_internal_extensions();
-       info.gid = -1;
-       info.uid = -1;
-       info.port = CONTEXT_PORT_NO_LISTEN;
-       //std::string ssl_key_path = "/home/michael/.ssh/id_rsa";
-       //info.ssl_ca_filepath = ssl_key_path.c_str();
-               
-       context = libwebsocket_create_context(&info);
-       //context = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN, NULL,protocols, libwebsocket_internal_extensions,NULL, NULL, -1, -1, 0);
-
-       setConfiguration(config);
-       re->setSupported(supported(), this);
-
-       //printf("websocketsource loaded!!!\n");
-       g_timeout_add(1000,checkTimeouts,this); //Do this once per second, check for functions that have timed out and reply with success = false;
-
-}
-PropertyList WebSocketSource::supported()
-{
-       return m_supportedProperties;
-}
-
-int WebSocketSource::supportedOperations()
-{
-       /// TODO: need to do this correctly based on what the host supports.
-       return Get | Set | GetRanged;
-}
-
-const string WebSocketSource::uuid()
-{
-       return "d293f670-f0b3-11e1-aff1-0800200c9a66";
-}
-
-void WebSocketSource::subscribeToPropertyChanges(VehicleProperty::Property property)
-{
-       //printf("Subscribed to property: %s\n",property.c_str());
-       queuedRequests.push_back(property);
-       if (clientConnected)
-       {
-               checkSubscriptions();
-       }
-}
-
-
-void WebSocketSource::unsubscribeToPropertyChanges(VehicleProperty::Property property)
-{
-       removeRequests.push_back(property);
-       if (clientConnected)
-       {
-               checkSubscriptions();
-       }
-}
-
-
-void WebSocketSource::getPropertyAsync(AsyncPropertyReply *reply)
-{
-       std::string uuid = amb::createUuid();
-       uuidReplyMap[uuid] = reply;
-       uuidTimeoutMap[uuid] = amb::currentTime() + 10.0; ///TODO: 10 second timeout, make this configurable?
-       stringstream s;
-       
-       s << "{\"type\":\"method\",\"name\":\"get\",\"data\":[\"" << reply->property << "\"],\"transactionid\":\"" << uuid << "\"}";
-       string replystr = s.str();
-       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Sending:" << replystr <<endl;
-       //printf("Reply: %s\n",replystr.c_str());
-       char *new_response = new char[LWS_SEND_BUFFER_PRE_PADDING + strlen(replystr.c_str()) + LWS_SEND_BUFFER_POST_PADDING];
-       new_response+=LWS_SEND_BUFFER_PRE_PADDING;
-       strcpy(new_response,replystr.c_str());
-       if(clientsocket)
-               libwebsocket_write(clientsocket, (unsigned char*)new_response, strlen(new_response), LWS_WRITE_TEXT);
-       delete (char*)(new_response-LWS_SEND_BUFFER_PRE_PADDING);
-}
-
-void WebSocketSource::getRangePropertyAsync(AsyncRangePropertyReply *reply)
-{
-       std::string uuid = amb::createUuid();
-       uuidRangedReplyMap[uuid] = reply;
-       uuidTimeoutMap[uuid] = amb::currentTime() + 60; ///TODO: 60 second timeout, make this configurable?
-       stringstream s;
-       s.precision(15);
-       s << "{\"type\":\"method\",\"name\":\"getRanged\",\"data\": {";
-
-       s << "\"properties\":[";
-
-       for (auto itr = reply->properties.begin(); itr != reply->properties.end(); itr++)
-       {
-               std::string prop = *itr;
-
-               if(itr != reply->properties.begin())
-               {
-                       s<<",";
-               }
-
-               s<<"\""<<prop<<"\"";
-       }
-
-       s<<"],";
-
-       s << "\"timeBegin\":\"" << reply->timeBegin << "\",";
-       s << "\"timeEnd\":\"" << reply->timeEnd << "\",";
-       s << "\"sequenceBegin\":\"" << reply->sequenceBegin<< "\",";
-       s << "\"sequenceEnd\":\"" << reply->sequenceEnd << "\"}";
-       s<< ",\"transactionid\":\"" << uuid << "\"}";
-       string replystr = s.str();
-       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Reply:" << replystr <<endl;
-       //printf("Reply: %s\n",replystr.c_str());
-       char *new_response = new char[LWS_SEND_BUFFER_PRE_PADDING + strlen(replystr.c_str()) + LWS_SEND_BUFFER_POST_PADDING];
-       new_response+=LWS_SEND_BUFFER_PRE_PADDING;
-       strcpy(new_response,replystr.c_str());
-       if(clientsocket)
-               libwebsocket_write(clientsocket, (unsigned char*)new_response, strlen(new_response), LWS_WRITE_TEXT);
-       delete (char*)(new_response-LWS_SEND_BUFFER_PRE_PADDING);
-}
-
-AsyncPropertyReply * WebSocketSource::setProperty( AsyncSetPropertyRequest request )
-{
-       ///TODO: fill in
-               AsyncPropertyReply* reply = new AsyncPropertyReply(request);
-       reply->success = true;
-       stringstream s;
-       s << "{\"type\":\"method\",\"name\":\"set\",\"data\":[\"property\" : \"" << request.property << "\",\"value\" : \"" << request.value << "\"],\"transactionid\":\"" << "d293f670-f0b3-11e1-aff1-0800200c9a66" << "\"}";
-       string replystr = s.str();
-       DebugOut() << __SMALLFILE__ <<":"<< __LINE__ << "Reply:" << replystr << "\n";
-       //printf("Reply: %s\n",replystr.c_str());
-       char *new_response = new char[LWS_SEND_BUFFER_PRE_PADDING + strlen(replystr.c_str()) + LWS_SEND_BUFFER_POST_PADDING];
-       new_response+=LWS_SEND_BUFFER_PRE_PADDING;
-       strcpy(new_response,replystr.c_str());
-       libwebsocket_write(clientsocket, (unsigned char*)new_response, strlen(new_response), LWS_WRITE_TEXT);
-       delete (char*)(new_response-LWS_SEND_BUFFER_PRE_PADDING);
-       reply->completed(reply);
-       return reply;
-}
-
-extern "C" AbstractSource * create(AbstractRoutingEngine* routingengine, map<string, string> config)
-{
-       return new WebSocketSource(routingengine, config);
-
-}
diff --git a/plugins/websocketsourceplugin/websocketsource.h b/plugins/websocketsourceplugin/websocketsource.h
deleted file mode 100644 (file)
index c44c725..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-
-/*
-Copyright (C) 2012 Intel Corporation
-
-This library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Lesser General Public
-License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this library; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-*/
-
-
-#ifndef WEBSOCKETSOURCE_H
-#define WEBSOCKETSOURCE_H
-
-
-
-#include <abstractsource.h>
-#include <string>
-#include <libwebsockets.h>
-
-
-class WebSocketSource : public AbstractSource
-{
-
-public:
-       WebSocketSource(AbstractRoutingEngine* re, std::map<std::string, std::string> config);
-       const std::string uuid();
-       void getPropertyAsync(AsyncPropertyReply *reply);
-       void getRangePropertyAsync(AsyncRangePropertyReply *reply);
-       AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
-       bool m_sslEnabled;
-       void subscribeToPropertyChanges(VehicleProperty::Property property);
-       void unsubscribeToPropertyChanges(VehicleProperty::Property property);
-       PropertyList supported();
-
-       int supportedOperations();
-
-       libwebsocket *clientsocket;
-       PropertyList queuedRequests;
-       bool clientConnected;
-       void checkSubscriptions();
-       PropertyList activeRequests;
-       PropertyList removeRequests;
-       void setSupported(PropertyList list);
-       void supportedChanged(PropertyList) {}
-       void setConfiguration(std::map<std::string, std::string> config);
-       //map<VehicleProperty::Property,AsyncPropertyReply*> propertyReplyMap;
-       //map<VehicleProperty::Property,AsyncRangePropertyReply*> rangedPropertyReplyMap;
-       std::map<std::string,AsyncPropertyReply*> uuidReplyMap;
-       std::map<std::string,double> uuidTimeoutMap;
-       std::map<std::string,AsyncRangePropertyReply*> uuidRangedReplyMap;
-       
-       PropertyInfo getPropertyInfo(VehicleProperty::Property property);
-
-private:
-       PropertyList m_supportedProperties;
-
-};
-
-#endif // WEBSOCKETSOURCE_H