]> git.vomp.tv Git - vompclient.git/commitdiff
23 CWFs
authorChris Tallon <chris@vomp.tv>
Wed, 19 Feb 2020 20:16:18 +0000 (20:16 +0000)
committerChris Tallon <chris@vomp.tv>
Wed, 19 Feb 2020 20:16:18 +0000 (20:16 +0000)
boxx.cc
tcp.cc
tcp.h
vdr.cc
vepg.cc
vepglistadvanced.cc
vrecordinglist.h
vrecordinglistadvanced.h
vrecordinglistclassic.h
vtimeredit.cc

diff --git a/boxx.cc b/boxx.cc
index 071ba987802c55e535f01af91b26c484f783954b..f3f6afff8b313f172b5bc83926f517cf442f5c3f 100644 (file)
--- a/boxx.cc
+++ b/boxx.cc
@@ -293,7 +293,7 @@ int Boxx::drawPara(const char* text, int x, int y, const DrawStyle& colour, unsi
   if (osdv) charwidtharray = osdv->getCharWidthArray();
 
   mbstate_t state;
-  memset((void*)&state, 0, sizeof(state));
+  memset(&state, 0, sizeof(state));
 
   while(1)
   {
diff --git a/tcp.cc b/tcp.cc
index 74eb7a3ec971d89655c65e14bbf1d931bfa44aa2..de01ee179092d5149a48e50519f71299163978f2 100644 (file)
--- a/tcp.cc
+++ b/tcp.cc
@@ -323,9 +323,9 @@ int TCP::sendData(void* bufR, size_t count)
   return(count);
 }
 
-int TCP::readData(UCHAR* buffer, int totalBytes)
+int TCP::readData(void* targetBuffer, int totalBytes)
 {
-
+  UCHAR* buffer = reinterpret_cast<UCHAR*>(targetBuffer);
   int bytesRead = 0;
   int thisRead;
   int readTries = 0;
diff --git a/tcp.h b/tcp.h
index 3b158eb7e1b0db7a28d7fa9d229579699d0f744f..524cfea53db1a4c2f1e69d6a86898808214e4a97 100644 (file)
--- a/tcp.h
+++ b/tcp.h
@@ -57,8 +57,8 @@ class TCP
     int isConnected();
     void disableTimeout();
 
-    int readData(UCHAR* buffer, int totalBytes);
-    int sendData(void *, size_t size);
+    int readData(void* buffer, int totalBytes);
+    int sendData(void*, size_t size);
 
     static void dump(unsigned char* data, ULONG size);
 
diff --git a/vdr.cc b/vdr.cc
index b7a28c3b178c62430d912e634718276d615c3cc9..3f218b771e48909c629dba2a8c1cae723b40c2ff 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -45,7 +45,7 @@
 #include "tvmedia.h"
 #include <climits>
 
-#define VOMP_PROTOCOLL_VERSION 0x00000500
+#define VOMP_PROTOCOL_VERSION 0x00000500
 
 VDR* VDR::instance = NULL;
 #ifdef VOMP_MEDIAPLAYER
@@ -336,7 +336,7 @@ void VDR::threadMethod()
   
   ULONG requestID;
   ULONG userDataLength;
-  UCHAR* userData;
+  void* userData;
 
   ULONG streamID;
   ULONG flag;
@@ -352,7 +352,7 @@ void VDR::threadMethod()
   {
     timeNow = time(NULL);
     
-    readSuccess = tcp->readData((UCHAR*)&channelID, sizeof(ULONG));  // 2s timeout atm
+    readSuccess = tcp->readData(&channelID, sizeof(ULONG));  // 2s timeout atm
 
     if (!readSuccess)
     {
@@ -394,21 +394,21 @@ void VDR::threadMethod()
 
     if (channelID == CHANNEL_REQUEST_RESPONSE)
     {
-      if (!tcp->readData((UCHAR*)&requestID, sizeof(ULONG))) break;
+      if (!tcp->readData(&requestID, sizeof(ULONG))) break;
       requestID = ntohl(requestID);
-      if (!tcp->readData((UCHAR*)&userDataLength, sizeof(ULONG))) break;
+      if (!tcp->readData(&userDataLength, sizeof(ULONG))) break;
       userDataLength = ntohl(userDataLength);
       if (userDataLength > 5000000) break; // how big can these packets get?
       userData = NULL;
       if (userDataLength > 0)
       {
-        userData = (UCHAR*)malloc(userDataLength);
+        userData = malloc(userDataLength);
         if (!userData) break;
         if (!tcp->readData(userData, userDataLength)) break;
       }
 
       vresp = new VDR_ResponsePacket();  
-      vresp->setResponse(requestID, userData, userDataLength);
+      vresp->setResponse(requestID, reinterpret_cast<UCHAR*>(userData), userDataLength);
       logger->log("VDR", Log::DEBUG, "Rxd a response packet, requestID=%lu, len=%lu", requestID, userDataLength);
 
       if (!edFindAndCall(vresp)) // makes ED lock, find receiver for vresp (using ed_cb_find() ) and then call (using ed_cb_call() )
@@ -420,24 +420,24 @@ void VDR::threadMethod()
     }
     else if (channelID == CHANNEL_STREAM || channelID == CHANNEL_TVMEDIA)
     {
-      if (!tcp->readData((UCHAR*)&streamID, sizeof(ULONG))) break;
+      if (!tcp->readData(&streamID, sizeof(ULONG))) break;
       streamID = ntohl(streamID);
 
-      if (!tcp->readData((UCHAR*)&flag, sizeof(ULONG))) break;
+      if (!tcp->readData(&flag, sizeof(ULONG))) break;
       flag = ntohl(flag);
 
-      if (!tcp->readData((UCHAR*)&userDataLength, sizeof(ULONG))) break; 
+      if (!tcp->readData(&userDataLength, sizeof(ULONG))) break;
       userDataLength = ntohl(userDataLength);
       userData = NULL;
       if (userDataLength > 0)
       {
-        userData = (UCHAR*)malloc(userDataLength);
+        userData = malloc(userDataLength);
         if (!userData) break;
         if (!tcp->readData(userData, userDataLength)) break;
       }
 
       vresp = new VDR_ResponsePacket();    
-      vresp->setStream(streamID, flag, userData, userDataLength, channelID);
+      vresp->setStream(streamID, flag, reinterpret_cast<UCHAR*>(userData), userDataLength, channelID);
       //logger->log("VDR", Log::DEBUG, "Rxd a stream packet, streamID=%lu, flag=%lu, len=%lu", streamID, flag, userDataLength);
 
       if (!edFindAndCall(vresp)) // makes ED lock, find receiver for vresp (using ed_cb_find() ) and then call (using ed_cb_call() )
@@ -450,8 +450,8 @@ void VDR::threadMethod()
     else if (channelID == CHANNEL_KEEPALIVE)
     {
       ULONG KAreply = 0;
-      if (!tcp->readData((UCHAR*)&KAreply, sizeof(ULONG))) break;
-      KAreply = (ULONG)ntohl(KAreply);
+      if (!tcp->readData(&KAreply, sizeof(ULONG))) break;
+      KAreply = ntohl(KAreply);
       if (KAreply == lastKAsent) // successful KA response
       {
         lastKAsent = 0;
@@ -493,7 +493,7 @@ void VDR::connectionDied()
   VDR_ResponsePacket* vresp;
   while(receivers.size())
   {
-    vdrpr = (VDR_PacketReceiver*) *(receivers.begin());
+    vdrpr = dynamic_cast<VDR_PacketReceiver*>(*(receivers.begin()));
     if (vdrpr->receiverChannel == CHANNEL_REQUEST_RESPONSE)
     {
       vresp = new VDR_ResponsePacket();
@@ -525,7 +525,7 @@ void VDR::connectionDied()
       edLock();
       
       for(EDRL::iterator i = receivers.begin(); i != receivers.end(); i++)
-        if ((VDR_PacketReceiver*)*i == vdrpr) { receivers.erase(i); break; }
+        if (dynamic_cast<VDR_PacketReceiver*>(*i) == vdrpr) { receivers.erase(i); break; }
     }
   }
   edUnlock();
@@ -540,8 +540,8 @@ bool VDR::ed_cb_find(EDReceiver* edr, void* userTag)
   // edr is a VDR_PacketReceiver object made in VDR::RequestResponse
   // userTag is a VDR_ResponsePacket made in threadMethod
 
-  VDR_PacketReceiver* vdrpr = (VDR_PacketReceiver*)edr;
-  VDR_ResponsePacket* vresp = (VDR_ResponsePacket*)userTag;
+  VDR_PacketReceiver* vdrpr = dynamic_cast<VDR_PacketReceiver*>(edr);
+  VDR_ResponsePacket* vresp = reinterpret_cast<VDR_ResponsePacket*>(userTag);
   
   // Is vresp for vdrpr ?
   
@@ -639,7 +639,7 @@ void VDR_PacketReceiver::call(void* userTag, bool& r_deregisterEDR, bool& r_wake
     // It's a RR. Save vresp and, signal the waiting thread and return.
     // VDR::RequestResponse will be blocking waiting for this to happen.
     // That function has a pointer to this object and can read save_vresp.
-    save_vresp = (VDR_ResponsePacket*)userTag;
+    save_vresp = reinterpret_cast<VDR_ResponsePacket*>(userTag);
 
     r_deregisterEDR = true;
     r_wakeThread = true;
@@ -649,7 +649,7 @@ void VDR_PacketReceiver::call(void* userTag, bool& r_deregisterEDR, bool& r_wake
   {
     // It's a stream packet. Pass off the stream data to streamReceiver,
     // delete the vresp. Keep this PacketReceiver for the next stream packet.
-    VDR_ResponsePacket* vresp = (VDR_ResponsePacket*)userTag;
+    VDR_ResponsePacket* vresp = reinterpret_cast<VDR_ResponsePacket*>(userTag);
     streamReceiver->streamReceive(vresp->getFlag(), vresp->getUserData(), vresp->getUserDataLength());
     delete vresp;
 
@@ -665,7 +665,7 @@ void VDR_PacketReceiver::call(void* userTag, bool& r_deregisterEDR, bool& r_wake
     // but am going to try setting this to false because I don't know that there is a thread to signal
     // delete the EDR. It's made once per media requested and wasn't owned/deleted by anything before
 
-    VDR_ResponsePacket* vresp = (VDR_ResponsePacket*)userTag;
+    VDR_ResponsePacket* vresp = reinterpret_cast<VDR_ResponsePacket*>(userTag);
     Log::getInstance()->log("VDR", Log::DEBUG, "TVMedia Pictures arrived VDR %x", vresp->getStreamID());
     OsdVector *osd=dynamic_cast<OsdVector*>(Osd::getInstance());
     if (osd) osd->getPictReader()->receivePicture(vresp);
@@ -703,7 +703,7 @@ int VDR::doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsigne
   *v_server_min=version_min;
   unsigned int version_max=vresp->extractULONG();
   *v_server_max=version_max;
-  *v_client=VOMP_PROTOCOLL_VERSION;
+  *v_client=VOMP_PROTOCOL_VERSION;
 
   if (0x00000302 <= version_max) {
          unsigned int numlangcodes = vresp->extractULONG();
@@ -722,8 +722,8 @@ int VDR::doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsigne
 
   delete vresp;
 
-  if ((version_min > VOMP_PROTOCOLL_VERSION)
-                 || (version_max < VOMP_PROTOCOLL_VERSION) ) {
+  if ((version_min > VOMP_PROTOCOL_VERSION)
+                 || (version_max < VOMP_PROTOCOL_VERSION) ) {
 
          return 0;
 
diff --git a/vepg.cc b/vepg.cc
index 71609d0e4b381706a0081f94c7447c82501e6758..4069109fa18abd9324ca1ab05def811f34f77cb0 100644 (file)
--- a/vepg.cc
+++ b/vepg.cc
@@ -219,7 +219,7 @@ void VEpg::setInfo(Event* event)
   int length = strlen(event->title); // calculate length of programme title string
   char* title = new char[length + 15]; // create string to hold start time, end time and programme title
   time_t eventtime = event->time;
-  LOCALTIME_R((time_t*)&eventtime, &btime); //get programme start time
+  LOCALTIME_R(&eventtime, &btime); //get programme start time
 #ifndef _MSC_VER
   strftime(timeString, 9, "%0H:%0M - ", &btime); // and format it as hh:mm -
 #else
index cf0c574dc862521fba3361f89ca10659ac138818..742ccffef542927211e30d8dd0ec7131fb25a911 100644 (file)
@@ -478,11 +478,11 @@ void VEpgListAdvanced::drawDataChannel(bool doIndexPop)
                  time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration);
 
                  LOCALTIME_R(&eventStartTime, &btime);
-                 strftime(tempA, 299, "%d/%m/%y %H:%M ", &btime);
+                 strftime(tempA, 300, "%d/%m/%y %H:%M ", &btime);
                  LOCALTIME_R(&eventEndTime, &btime);
-                 strftime(tempB, 299, "- %H:%M ", &btime);
-                 //#endif
-                 sprintf(tempC, "\t %s\n \t \t%s%s", currentEvent->title,tempA,tempB);
+                 strftime(tempB, 300, "- %H:%M ", &btime);
+                 int check = SNPRINTF(tempC, 300, "\t %s\n \t \t%s%s", currentEvent->title,tempA,tempB);
+          if ((check < 0) || (check > 299)) Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "String too big");
                  // New TVMedia stuff
                  TVMediaInfo *info= new TVMediaInfo();
                  info->setPosterThumb(channelNumber, currentEvent->id);
@@ -545,12 +545,11 @@ void VEpgListAdvanced::drawDataNowNext(bool next, bool doIndexPop)
                  time_t eventEndTime = (time_t)(currentEvent->time + currentEvent->duration);
 
                  LOCALTIME_R(&eventStartTime, &btime);
-                 strftime(tempA, 299, "%H:%M ", &btime);
+                 strftime(tempA, 300, "%H:%M ", &btime);
                  LOCALTIME_R(&eventEndTime, &btime);
-                 strftime(tempB, 299, "- %H:%M ", &btime);
-                 //#endif
-                 sprintf(tempC, "%s\n%s\t %s%s", currentEvent->title, chan->name,tempA,tempB);
-
+                 strftime(tempB, 300, "- %H:%M ", &btime);
+                 int check = SNPRINTF(tempC, 300, "%s\n%s\t %s%s", currentEvent->title, chan->name,tempA,tempB);
+          if ((check < 0) || (check > 299)) Log::getInstance()->log("VEventListAdvanced", Log::DEBUG, "String too big");
          } else {
                  sprintf(tempC, "\n%s", chan->name);
 
index 7f49b27ff88027536f8a3fe7e42e00e7a4742446..f9ec04efbad08b7e625490e75fdebf21b89b6016 100644 (file)
@@ -42,7 +42,9 @@ class VRecordingList : public TBBoxx
     VRecordingList();
     virtual ~VRecordingList();
 
-    using TBBoxx::draw;
+#ifndef WIN32
+    using TBBoxx::draw; // Signal the compiler we are intentionally overriding the draw() virtual with different args
+#endif
     virtual void draw(bool doIndexPop = false)=0;
 
     int handleCommand(int command);
index c55edb676024737051d8c6ce84edc391e3261ee4..f9dc189e064dedab13393dfa8724046d6bbe67e0 100644 (file)
@@ -30,7 +30,9 @@ class VRecordingListAdvanced : public VRecordingList
     VRecordingListAdvanced();
     virtual ~VRecordingListAdvanced();
 
+#ifndef WIN32
     using TBBoxx::draw; // Signal the compiler we are intentionally overriding the draw() virtual with different args
+#endif
     void draw(bool doIndexPop = false);
 
     bool load();
index 2d056ca526caa2c154a87aff1363f8c5aa680358..ebd91563dccef68563ea0efcb33656951607f3bd 100644 (file)
@@ -28,7 +28,9 @@ class VRecordingListClassic : public VRecordingList
     VRecordingListClassic();
     virtual ~VRecordingListClassic();
 
-    using TBBoxx::draw;
+#ifndef WIN32
+    using TBBoxx::draw; // Signal the compiler we are intentionally overriding the draw() virtual with different args
+#endif
     void draw(bool doIndexPop = false);
 
     bool load();
index da078708ed127c97ce19430e91ee91024bca28b3..0d2f97b45f3cb0988f6285dcff7b6a850fd682cb 100644 (file)
@@ -120,13 +120,13 @@ void VTimerEdit::draw()
 
   // Start
   time_t rectime = recTimer->startTime;
-  LOCALTIME_R((time_t*)&rectime, &tms);
+  LOCALTIME_R(&rectime, &tms);
   strftime(buffer, 999, "%d/%m %H:%M", &tms);
   drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT);         ypos += fontheight;
 
   // Stop
   rectime = recTimer->stopTime;
-  LOCALTIME_R((time_t*)&rectime, &tms);
+  LOCALTIME_R(&rectime, &tms);
   strftime(buffer, 999, "%d/%m %H:%M", &tms);
   drawText(buffer, xpos, ypos, DrawStyle::LIGHTTEXT);         ypos += fontheight;