Browse Source

change tool/map_lanetoxodr. add license check.

yuchuli 3 years ago
parent
commit
7248f4af5d

+ 7 - 0
src/common/common/license/adclicense.pri

@@ -0,0 +1,7 @@
+HEADERS += \
+    $$PWD/adclicenseserv.h \
+    $$PWD/adclicensewithwin.h
+
+SOURCES += \
+    $$PWD/adclicenseserv.cpp \
+    $$PWD/adclicensewithwin.cpp

+ 71 - 0
src/common/common/license/adclicenseserv.cpp

@@ -0,0 +1,71 @@
+#include "adclicenseserv.h"
+
+#include <QProcess>
+#include "modulecomm.h"
+#include <thread>
+#include <iostream>
+
+namespace iv {
+struct ivlicensekey
+{
+    bool linshikey;
+    bool yongjiukey;
+};
+}
+
+
+iv::ivlicensekey gkey;
+void * gpa;
+bool gbHaveRecvKey = false;
+
+
+
+ADCLicenseServ::ADCLicenseServ()
+{
+
+}
+
+void ListenKey(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+{
+
+    std::cout<<"key len is "<<nSize<<std::endl;
+    if(nSize >= sizeof (iv::ivlicensekey))
+    {
+        memcpy(&gkey,strdata,sizeof(iv::ivlicensekey));
+        std::cout<<" key 1:"<<gkey.linshikey<<"key 2:"<<gkey.yongjiukey<<std::endl;
+        gbHaveRecvKey = true;
+    }
+
+}
+
+
+int ADCLicenseServ::CheckLincese()
+{
+    gpa = iv::modulecomm::RegisterRecv("keyfeedback",ListenKey);
+    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+    QProcess * pProc = new QProcess();
+//    pProc->start("adc_key_win_exe.exe");
+    QTime xTime;
+    xTime.start();
+    while(gbHaveRecvKey == false)
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(1));
+        if(xTime.elapsed()>10000)
+        {
+            break;
+        }
+    }
+    if(gbHaveRecvKey)
+    {
+        if((gkey.yongjiukey == true)||(gkey.linshikey == true))
+        {
+            return  0;
+        }
+        else
+        {
+            return  -1;
+        }
+    }
+    return -2;
+
+}

+ 14 - 0
src/common/common/license/adclicenseserv.h

@@ -0,0 +1,14 @@
+#ifndef ADCLICENSESERV_H
+#define ADCLICENSESERV_H
+
+
+class ADCLicenseServ
+{
+public:
+    ADCLicenseServ();
+
+public:
+    static int CheckLincese();
+};
+
+#endif // ADCLICENSESERV_H

+ 22 - 0
src/common/common/license/adclicensewithwin.cpp

@@ -0,0 +1,22 @@
+
+#include <QMessageBox>
+#include "adclicenseserv.h"
+
+int ADCLicenseCheckWithWin()
+{
+    int nRtn = ADCLicenseServ::CheckLincese();
+    if(nRtn == -1)
+    {
+        QMessageBox::warning(NULL,"Warning","License 错误,请申请Lincense",QMessageBox::YesAll);
+        return nRtn;
+    }
+    else
+    {
+        if(nRtn == -2)
+        {
+            QMessageBox::warning(NULL,"Warning","License服务启动失败",QMessageBox::YesAll);
+            return nRtn;
+        }
+    }
+    return nRtn;
+}

+ 5 - 0
src/common/common/license/adclicensewithwin.h

@@ -0,0 +1,5 @@
+#ifndef ADCLICENSEWITHWIN_H
+#define ADCLICENSEWITHWIN_H
+
+int ADCLicenseCheckWithWin();
+#endif // ADCLICENSEWITHWIN_H

+ 5 - 0
src/tool/map_lanetoxodr/main.cpp

@@ -13,6 +13,7 @@
 
 #include <QApplication>
 
+#include "adclicensewithwin.h"
 
 #ifdef ANDROID
 #include <QAndroidJniEnvironment>
@@ -75,6 +76,10 @@ int main(int argc, char *argv[])
 #ifdef XODRViewer
     XVMainWindow w;
 #else
+    if(ADCLicenseCheckWithWin() != 0)
+    {
+//        return 0;
+    }
     MainWindow w;
 #endif
     w.show();

+ 5 - 0
src/tool/map_lanetoxodr/map_lanetoxodr.pro

@@ -146,6 +146,10 @@ FORMS += \
     error( "Couldn't find the OpenDrive.pri file!" )
 }
 
+!include(../../common/common/license/adclicense.pri ) {
+    error( "Couldn't find the adclicense.pri file!" )
+}
+
 unix:LIBS += -lboost_thread -lboost_system -lboost_serialization -lprotobuf
 
 
@@ -162,6 +166,7 @@ LIBS += -L$$PWD/../../../bin/ -lxmlparam -lmodulecomm -livlog -livfault -livback
 INCLUDEPATH += $$PWD/../../include/msgtype
 
 INCLUDEPATH += $$PWD/../../common/common/xodr
+INCLUDEPATH += $$PWD/../../common/common/license
 
 
 #DEFINES += OPENDRIVE_EDITONLY