8.5.5.2 SecureDELTA SDK QT Sample App Main File


   SecureDELTA QT Sample Application main file


The listing for SD_SDK_SecureDELTA_QT_ModuleWnd.cpp


  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
///////////////////////////////////////////////////////////////////////
//                                                                     
// SecureDELTA SDK QT DEMO APPLICATION                                 
// Part of SecureDELTA SDK v2.56 (C) agersoftware srl                  
//                                                                     
// Designed, developed and implemented by agersoftware srl and its     
// technology partner, NetLUP Xtreme Technologies srl                  
//                                                                     
// Copyright (C) 2019-2029 agersoftware srl, All Rights Reserved.      
// Portions Copyright (C) 2019-2029 NetLUP Xtreme Technologies srl.    
//                                                                     
// NOTICE:                                                             
// All information contained herein is and remains the property of     
// agersoftware srl and its suppliers or technological partners        
// NetLUP Xtreme Technologies srl                                      
//                                                                     
// INTELLECTUAL PROPERTY                                               
// The intellectual and technical concepts contained herein are also   
// proprietary to agersoftware srl and its suppliers or technological  
// partner NetLUP Xtreme Technologies srl and are protected by trade   
// secret or copyright law.                                            
//                                                                     
// CONFIDENTIAL                                                        
// Dissemination of this information or reproduction of this material  
// is strictly forbidden unless prior written permission is obtained   
// from agersoftware srl or NetLUP Xtreme Technologies srl.            
//                                                                     
// COPYRIGHT                                                           
// This software is provided by the copyright holders and technology   
// partners "as is" and any express or implied warranties, including,  
// but not limited to, the implied warranties of merchantability and   
// fitness for a particular purpose are disclaimed.                    
//                                                                     
// NO LIABILITY                                                        
// In no event shall the copyright owner or technology partners be     
// liable for any direct, indirect, incidental, special, exemplary, or 
// consequential damages(including, but not limited to, procurement    
// of  substitute goods or services; loss of use, data, or profits;    
// or business interruption) however caused and on any theory of       
// liability, whether in contract, strict liability, or tort           
// (including negligence or otherwise)  arising in any way out of the  
// use of this software, even if advised of the possibility of such    
// damage.                                                             
//                                                                     
// INFO & CONTACT                                                      
// securesdk@securedelta.eu | securesdkinfo@agersoftware.com           
//                                                                     
///////////////////////////////////////////////////////////////////////

#include <QFileDialog>
#include <QDesktopServices>
#include <QMessageBox>
#include <QUrl>
#include <QLibrary>

#define _X86_

#include <string>
#include <windows.h>

#include "SD_SDK_SecureDELTA_QT_ModuleWnd.h"
#include "ui_SD_SDK_SecureDELTA_QT_ModuleWnd.h"

#include "../SecureDELTA_SDK_Includes\SecureEncodeSDK.h"
#include "../SecureDELTA_SDK_Includes\SecureDecodeSDK.h"

typedef int32_t (__stdcall *QT_SD_SDK_SecureENCODE_Prototype)(SD_SDK_SECURE_ENCODE_PARAMS&);
typedef int32_t (__stdcall *QT_SD_SDK_SecureDECODE_Prototype)(SD_SDK_SECURE_DECODE_PARAMS&);

const wchar_t* _wchr_SecureENCODE_DLL = L"../Bin_x86/SecureENCODE_SDK_DLL_x86.dll";
const wchar_t* _wchr_SecureDECODE_DLL = L"../Bin_x86/SecureDECODE_SDK_DLL_x86.dll";

QT_SD_SDK_SecureENCODE_Prototype  pf_SecureENCODE_FunctionMain = 0;
QT_SD_SDK_SecureDECODE_Prototype  pf_SecureDECODE_FunctionMain = 0;

SD_SDK_SECURE_ENCODE_RETURN_ID __stdcall secure_delta_encode_callback_funct(_SD_SDK_SECURE_ENCODE_CALLBACK_EVENT _cb_event, void *p_delta_encode_user_data)
{
        SD_SDK_SECUREDELTA_DemoWnd* pUpdaterObject = (SD_SDK_SECUREDELTA_DemoWnd*)p_delta_encode_user_data;
        if( pUpdaterObject && pUpdaterObject->isWindow())
        {
             QCoreApplication::processEvents();
             pUpdaterObject->UpdateProgress_currentOperation(_cb_event.dbl_operation_progress_indicator);
             pUpdaterObject->UpdateProgress_mainOperation(_cb_event.uint_main_progress_indicator);
        }
        return SD_SDK_ENCODE_NO_ERROR_;
}

SD_SDK_SECURE_DECODE_RETURN_ID __stdcall secure_delta_decode_callback_funct(_SD_SDK_SECURE_DECODE_CALLBACK_EVENT _cb_event, void *p_delta_decode_user_data, HWND hCallerHWnd)
{
        SD_SDK_SECUREDELTA_DemoWnd* pUpdaterObject = (SD_SDK_SECUREDELTA_DemoWnd*)p_delta_decode_user_data;
        if( pUpdaterObject && pUpdaterObject->isWindow())
        {
             QCoreApplication::processEvents();
             pUpdaterObject->UpdateProgress_currentOperation(_cb_event.dbl_operation_progress_indicator);
             pUpdaterObject->UpdateProgress_mainOperation(_cb_event.uint_main_progress_indicator);
        }
        return SD_SDK_DECODE_NO_ERROR_;
}

void SD_SDK_SECUREDELTA_DemoWnd::UpdateProgress_currentOperation(int32_t progress)
{
    ui->progressBar_1->setValue(progress);
}

void SD_SDK_SECUREDELTA_DemoWnd::UpdateProgress_mainOperation(int32_t progress)
{
    ui->progressBar_2->setValue(progress);
}

SD_SDK_SECUREDELTA_DemoWnd::SD_SDK_SECUREDELTA_DemoWnd(QWidget *parent) : QMainWindow(parent), ui(new Ui::SD_SDK_SECUREDELTA_DemoWnd)
{
    ui->setupUi(this);

    //
    // SecureENCODE
    //

    QString qtStrE("");
    HMODULE  dll_SecureENCODE_HModule = LoadLibrary(_wchr_SecureENCODE_DLL);
    if(dll_SecureENCODE_HModule != 0)
    {
       pf_SecureENCODE_FunctionMain = (QT_SD_SDK_SecureENCODE_Prototype)GetProcAddress(dll_SecureENCODE_HModule, SecureDELTA_SDK_DLL_SecureENCODE_Main_Func_);

       if(NULL != pf_SecureENCODE_FunctionMain)
       {
           qtStrE = "Successfuly loaded " + QString::fromWCharArray(_wchr_SecureENCODE_DLL);
           qtStrE += "\nSuccessfuly found Main Export from SecureENCODE DLL!";
       }
    }
    else
    {
        qtStrE = "Failed loading " + QString::fromWCharArray(_wchr_SecureENCODE_DLL);
    }
    ui->statusEditSecureENCODE->setText(qtStrE);

    //
    // SecureDECODE
    //
    QString qtStrD("");
    HMODULE  dll_SecureDECODE_HModule = LoadLibrary(_wchr_SecureDECODE_DLL);
    if(dll_SecureDECODE_HModule != 0)
    {
       pf_SecureDECODE_FunctionMain = (QT_SD_SDK_SecureDECODE_Prototype)GetProcAddress(dll_SecureDECODE_HModule, SecureDELTA_SDK_DLL_SecureDECODE_Main_Func_);

       if(NULL != pf_SecureDECODE_FunctionMain)
       {
           qtStrD = "Successfuly loaded " + QString::fromWCharArray(_wchr_SecureDECODE_DLL);
           qtStrD += "\nSuccessfuly found Main Export from SecureDECODE DLL!";
       }
    }
    else
    {
        qtStrD = "Failed loading " + QString::fromWCharArray(_wchr_SecureDECODE_DLL);
    }

    ui->statusEditSecureDECODE->setText(qtStrD);

    UpdateProgress_currentOperation(0);
    UpdateProgress_mainOperation(0);
}

SD_SDK_SECUREDELTA_DemoWnd::~SD_SDK_SECUREDELTA_DemoWnd()
{
    delete ui;
}

void SD_SDK_SECUREDELTA_DemoWnd::on_browseForSourceFilenameEncode_clicked()
{
    QString fileName = QFileDialog::getOpenFileName(this, tr("Choose any file"), "", tr("All files (*.*)"));

    if(fileName != "") {
        ui->edtSourceFilenameEncode->setText(fileName);
        ui->edtSourceFilenameDecode->setText(fileName);
    }
}

void SD_SDK_SECUREDELTA_DemoWnd::on_browseForTargetFilenameEncode_clicked()
{
    QString fileName = QFileDialog::getOpenFileName(this, tr("Choose any file"), "", tr("All files (*.*)"));

    if(fileName != "") {
        ui->edtTargetFilenameEncode->setText(fileName);
        ui->edtSecureDeltaFilenameEncode->setText(fileName + ".secureDELTA");
    }
}

void SD_SDK_SECUREDELTA_DemoWnd::on_browseForSourceFilenameDecode_clicked()
{
    QString fileName = QFileDialog::getOpenFileName(this, tr("Choose any file"), "", tr("All files (*.*)"));

    if(fileName != "") {
        ui->edtSourceFilenameDecode->setText(fileName);
        ui->edtNewTargetFilenameDecode->setText(fileName + ".NEW_Target");
    }
}

void SD_SDK_SECUREDELTA_DemoWnd::on_browseForSecureDELTAFilenameDecode_clicked()
{
    QString fileName = QFileDialog::getOpenFileName(this, tr("Choose any file"), "", tr("All files (*.*)"));
    if(fileName != "") {
        ui->edtSecureDeltaFilenameDecode->setText(fileName);
    }
}

void SD_SDK_SECUREDELTA_DemoWnd::on_actionVisit_us_at_www_agersoftware_com_triggered()
{
    QDesktopServices::openUrl(QUrl("https://www.agersoftware.com/"));
}

void SD_SDK_SECUREDELTA_DemoWnd::on_actionAbout_triggered()
{
     const QString csTitle = "About SecureDELTA SDK QT DEMO Applicaton";
     const QString csTitleVer = "SecureDELTA SDK ver 2.36.108";

     QMessageBox ab;
     ab.about(this, csTitle, csTitleVer);
}

void SD_SDK_SECUREDELTA_DemoWnd::on_label_linkActivated(const QString&)
{
    QDesktopServices::openUrl(QUrl("https://www.agersoftware.com/"));
}

void SD_SDK_SECUREDELTA_DemoWnd::on_btnSecureENCODE_clicked()
{
    QString qtStr;
    int useXtremeDelta = ui->checkBoxXtremeDELTA->isChecked() ? 0x01 : 0x00;

    SD_SDK_SECURE_ENCODE_PARAMS _secure_encode_paramStruct;

    QString _source_filename = ui->edtSourceFilenameEncode->text();
    _source_filename.toWCharArray(_secure_encode_paramStruct._wchr_sourcefile_path);

    QString _target_filename = ui->edtTargetFilenameEncode->text();
    _target_filename.toWCharArray(_secure_encode_paramStruct._wchr_targetfile_path);

    QString _secureDelta_filename = ui->edtSecureDeltaFilenameEncode->text();
    _secureDelta_filename.toWCharArray(_secure_encode_paramStruct._wchr_securedelta_path);

    wcsncpy_s( _secure_encode_paramStruct._wchr_versionSource, L"v1.100.120" , _SD_SDK_MAX_VER_);
    wcsncpy_s( _secure_encode_paramStruct._wchr_versionTarget, L"v1.200.020" , _SD_SDK_MAX_VER_);

    _secure_encode_paramStruct._use_callback = 0x01;
    _secure_encode_paramStruct._callback_user_hwnd =  (HWND)this->winId();
    _secure_encode_paramStruct._callback_p_user_data = this;
    _secure_encode_paramStruct._sd_sdk_secure_callback_function = (pf_secure_encode_sdk_event_cb)secure_delta_encode_callback_funct;

    _secure_encode_paramStruct._use_xtreme_mode = useXtremeDelta;

    int32_t result_secureENCODE = -1;

    if(NULL != pf_SecureENCODE_FunctionMain)
    {
        result_secureENCODE = pf_SecureENCODE_FunctionMain(_secure_encode_paramStruct);
    }

    const QString csTitle = "SecureDELTA SDK - SecureENCODE Done!";
    const QString csTitleVer = (result_secureENCODE == 0x00) ? "SecureENCODE operation ended Succesfuly" : ("SecureENCODE operation ended with error: " + QString::number(result_secureENCODE));

    QMessageBox ab;
    ab.about(this, csTitle, csTitleVer);
}

void SD_SDK_SECUREDELTA_DemoWnd::on_btnSecureDECODE_clicked()
{
    QString qtStr;

    SD_SDK_SECURE_DECODE_PARAMS _secure_decode_paramStruct;

    QString _source_filename = ui->edtSourceFilenameDecode->text();
    _source_filename.toWCharArray(_secure_decode_paramStruct._wchr_sourcefile_path);

    QString _target_filename = ui->edtNewTargetFilenameDecode->text();
    _target_filename.toWCharArray(_secure_decode_paramStruct._wchr_targetfile_path);

    QString _secureDelta_filename = ui->edtSecureDeltaFilenameDecode->text();
    _secureDelta_filename.toWCharArray(_secure_decode_paramStruct._wchr_securedelta_path);

    _secure_decode_paramStruct._use_callback = 0x01;
    _secure_decode_paramStruct._callback_p_user_data = this;
    _secure_decode_paramStruct._callback_user_hwnd =  (HWND)this->winId();
    _secure_decode_paramStruct._sd_sdk_secure_callback_function = (pf_secure_decode_sdk_event_cb)secure_delta_decode_callback_funct;

    int32_t result_secureDECODE = -1;

    if(NULL != pf_SecureDECODE_FunctionMain)
    {
       result_secureDECODE = pf_SecureDECODE_FunctionMain(_secure_decode_paramStruct);
    }

    const QString csTitle = "SecureDELTA SDK - SecureDECODE Done!";
    const QString csTitleVer = (result_secureDECODE == 0x00) ? "SecureDECODE operation ended Succesfuly" :  ("SecureDENCODE operation ended with error: " + QString::number(result_secureDECODE));

    QMessageBox ab;
    ab.about(this, csTitle, csTitleVer);
}