edits
[iotcloud.git] / version2 / src / C / CloudComm.h
index cdec4950174c55e4fd22566bda37a22ae3337d1e..2f825083214a26608087b08b656d575c59004119 100644 (file)
@@ -2,7 +2,7 @@
 #define CLOUDCOMM_H
 
 #include "common.h"
-
+#include <pthread.h>
 /**
  * This class provides a communication API to the webserver.  It also
  * validates the HMACs on the slots and handles encryption.
 #define CloudComm_IV_SIZE 16
 /** Sets the size for the HMAC. */
 #define CloudComm_HMAC_SIZE 32
+#define HttpURLConnection_HTTP_OK 200
+
 
 class CloudComm {
 private:
        IoTString *baseurl;
-       SecretKeySpec *key;
+       AESKey *key;
        Mac *mac;
        IoTString *password;
        SecureRandom *random;
        Array<char> *salt;
        Table *table;
        int32_t listeningPort;
-       Thread *localServerThread;
+       pthread_t localServerThread;
        bool doEnd;
        TimingSingleton *timer;
 
        /**
         * Generates Key from password.
         */
-       SecretKeySpec *initKey();
+       AESKey *initKey();
 
        /**
         * Inits the HMAC generator.
@@ -44,14 +46,14 @@ private:
        /*
         * Builds the URL for the given request.
         */
-       URL *buildRequest(bool isput, int64_t sequencenumber, int64_t maxentries);
+       IoTString *buildRequest(bool isput, int64_t sequencenumber, int64_t maxentries);
        void setSalt();
        bool getSalt();
        Array<char> *createIV(int64_t machineId, int64_t localSequenceNumber);
        Array<char> *encryptSlotAndPrependIV(Array<char> *rawData, Array<char> *ivBytes);
        Array<char> *stripIVAndDecryptSlot(Array<char> *rawData);
-       Array<Slot *> *processSlots(DataInputStream dis);
-       void localServerWorkerFunction();
+       Array<Slot *> *processSlots(int fd);
+
 
 public:
        /**
@@ -90,5 +92,6 @@ public:
 
        Array<char> *sendLocalData(Array<char> *sendData, int64_t localSequenceNumber, IoTString *host, int port);
        void close();
+       void localServerWorkerFunction();
 };
 #endif