Projet

Général

Profil

Révision a469d718

Voir les différences:

.bzrignore
1
./lib/abuleduapplicationv1
2
./lib/abuleduconstantesv1
3
./lib/abuledunetworkaccessmanagerv1
4
./lib/abuledumessageboxv1
5
./lib/abuleduidentitesv1
6
./lib/abuleduflatboutonv1
7
./lib/maia
8
./lib/abuledufilev1
9
./lib/abuleduvirtualkeyboardv1
10
./lib/abuledusplashscreenv1
.bzrmeta/externals
1
http://redmine.ryxeo.com/code/leterrier-developpeu/abuleduapplicationv1 lib/abuleduapplicationv1
2
http://redmine.ryxeo.com/code/leterrier-developpeu/abuleduconstantesv1/ lib/abuleduconstantesv1
3
http://redmine.ryxeo.com/code/leterrier-developpeu/abuledunetworkaccessmanagerv1/ lib/abuledunetworkaccessmanagerv1
4
http://redmine.ryxeo.com/code/leterrier-developpeu/abuledumessageboxv1/ lib/abuledumessageboxv1
5
http://redmine.ryxeo.com/code/leterrier-developpeu/abuleduidentitesv1/ lib/abuleduidentitesv1
6
http://redmine.ryxeo.com/code/leterrier-developpeu/abuleduflatboutonv1/ lib/abuleduflatboutonv1
7
http://redmine.ryxeo.com/code/leterrier-developpeu/maia/ lib/maia
8
http://redmine.ryxeo.com/code/leterrier-developpeu/abuledufilev1/ lib/abuledufilev1
9
http://redmine.ryxeo.com/code/leterrier-developpeu/abuleduvirtualkeyboardv1 lib/abuleduvirtualkeyboardv1
10
http://redmine.ryxeo.com/code/leterrier-developpeu/abuledusplashscreenv1 lib/abuledusplashscreenv1
.bzrmeta/externals-snapshot
1
http://redmine.ryxeo.com/code/leterrier-developpeu/abuleduapplicationv1 lib/abuleduapplicationv1 revid:philippe.cadaugade@ryxeo.com-20130624142256-6lprlvfcn72pwi8s
2
http://redmine.ryxeo.com/code/leterrier-developpeu/abuleduconstantesv1/ lib/abuleduconstantesv1 revid:eric.seigne@ryxeo.com-20130321094714-9zwblepyl2ietis1
3
http://redmine.ryxeo.com/code/leterrier-developpeu/abuledunetworkaccessmanagerv1/ lib/abuledunetworkaccessmanagerv1 revid:eric.seigne@ryxeo.com-20130319110634-vgopg53n3qf7sj06
4
http://redmine.ryxeo.com/code/leterrier-developpeu/abuledumessageboxv1/ lib/abuledumessageboxv1 revid:philippe.cadaugade@ryxeo.com-20130614154345-7y8ky71k7h9ahe4b
5
http://redmine.ryxeo.com/code/leterrier-developpeu/abuleduidentitesv1/ lib/abuleduidentitesv1 revid:eric.seigne@ryxeo.com-20130322103554-l8fc3fp1wqfhrhh7
6
http://redmine.ryxeo.com/code/leterrier-developpeu/abuleduflatboutonv1/ lib/abuleduflatboutonv1 revid:philippe.cadaugade@ryxeo.com-20130506133852-x8yq8e04le150pt8
7
http://redmine.ryxeo.com/code/leterrier-developpeu/maia/ lib/maia revid:icham.sirat@ryxeo.com-20130313214413-0n1fpronm8lnatul
8
http://redmine.ryxeo.com/code/leterrier-developpeu/abuledufilev1/ lib/abuledufilev1 revid:philippe.cadaugade@ryxeo.com-20130624142451-lqk44f6dqi2uv7qn
9
http://redmine.ryxeo.com/code/leterrier-developpeu/abuleduvirtualkeyboardv1 lib/abuleduvirtualkeyboardv1 revid:icham.sirat@ryxeo.com-20130506093314-en1m115ntenz1kg6
10
http://redmine.ryxeo.com/code/leterrier-developpeu/abuledusplashscreenv1 lib/abuledusplashscreenv1 revid:philippe.cadaugade@ryxeo.com-20130417095431-ec6asrvaxso8zns7
main.cpp
1
/** Projet ryxeo-antivirus
2
  *
3
  * @see https://redmine.ryxeo.com/projects/ryxeo-antivirus
4
  * @author 2013 Eric Seigne <eric.seigne@ryxeo.com
5
  * @see The GNU Public License (GPL)
6
  *
7
  * This program is free software; you can redistribute it and/or modify
8
  * it under the terms of the GNU General Public License as published by
9
  * the Free Software Foundation; either version 3 of the License, or
10
  * (at your option) any later version.
11
  *
12
  * This program is distributed in the hope that it will be useful, but
13
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
  * for more details.
16
  *
17
  * You should have received a copy of the GNU General Public License along
18
  * with this program. If not, see <http://www.gnu.org/licenses/>.
19
  */
20

  
21

  
22
#include <QtGui/QApplication>
23
#include <QTranslator>
24
#include <QLocale>
25
#include <QDebug>
26

  
27
#include "version.h"
28
#include "utilitairemainwindow.h"
29
#include "abuleduapplicationv1.h"
30
#include "abuledusplashscreenv1.h"
31

  
32
int main(int argc, char *argv[])
33
{
34
    AbulEduApplicationV1 a(argc, argv,VER_INTERNALNAME_STR, VER_PRODUCTVERSION_STR, VER_COMPANYDOMAIN_STR, "abuledu");
35
    a.setAbeApplicationLongName(QObject::trUtf8(VER_FILEDESCRIPTION_STR));
36
    UtilitaireMainWindow *w;
37
    
38
    // ================== splashscreen
39
    AbulEduSplashScreenV1 *splash = new AbulEduSplashScreenV1(0,true);
40
    splash->show();
41
    w = new UtilitaireMainWindow();
42
    splash->setMainWindow(w);
43
    //pour les developpeurs presses, remplacer le 1000 par 100
44
    splash->launch(1000);
45
    // ================== splashscreen end
46

  
47
    return a.exec();
48
}
49

  
ryxeo-antivirus.pro
1
QT       += core gui script xml network svg phonon
2
system(ccache -V):QMAKE_CXX = ccache g++
3

  
4

  
5
TEMPLATE = app
6

  
7
SOURCES += main.cpp \
8
           utilitairemainwindow.cpp
9

  
10
HEADERS  += version.h \
11
            utilitairemainwindow.h
12

  
13
FORMS += utilitairemainwindow.ui
14

  
15

  
16
win32{
17
  OTHER_FILES += windows/windows.rc
18
  RC_FILE = windows/windows.rc
19
}
20

  
21
macx {
22
 ICON = macos/icones/macos.icns
23
}
24

  
25
include(lib/abuleduapplicationv1/abuleduapplicationv1.pri)
26
include(lib/abuleduconstantesv1/abuleduconstantesv1.pri)
27
include(lib/abuledunetworkaccessmanagerv1/abuledunetworkaccessmanagerv1.pri)
28
include(lib/abuledumessageboxv1/abuledumessageboxv1.pri)
29
include(lib/abuleduidentitesv1/abuleduidentitesv1.pri)
30
include(lib/abuleduflatboutonv1/abuleduflatboutonv1.pri)
31
include(lib/maia/maia.pri)
32
include(lib/abuledufilev1/abuledufilev1.pri)
33
#include(lib/abuleduvirtualkeyboardv1/abuleduvirtualkeyboardv1.pri)
34
include(lib/abuledusplashscreenv1/abuledusplashscreenv1.pri)
utilitairemainwindow.cpp
1
/** Classe de base pour les mainwindows des logiciels AbulEdu (ryxeo-antivirus)
2
  *
3
  * @see https://redmine.ryxeo.com/projects/ryxeo-antivirus
4
  * @author 2013 Eric Seigne <eric.seigne@ryxeo.com
5
  * 
6
  * @see https://redmine.ryxeo.com/projects/ryxeo/wiki/UtilitaireMainWindow
7
  * @author 2012 Philippe <philippe.cadaugade@ryxeo.com>
8
  *
9
  * @see The GNU Public License (GPL)
10
  *
11
  * This program is free software; you can redistribute it and/or modify
12
  * it under the terms of the GNU General Public License as published by
13
  * the Free Software Foundation; either version 2 of the License, or
14
  * (at your option) any later version.
15
  *
16
  * This program is distributed in the hope that it will be useful, but
17
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18
  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19
  * for more details.
20
  *
21
  * You should have received a copy of the GNU General Public License along
22
  * with this program; if not, write to the Free Software Foundation, Inc.,
23
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
  */
25

  
26
#include "utilitairemainwindow.h"
27
#include "ui_utilitairemainwindow.h"
28

  
29
UtilitaireMainWindow::UtilitaireMainWindow(QWidget *parent) :
30
    QMainWindow(parent),
31
    ui(new Ui::UtilitaireMainWindow)
32
{
33
    ui->setupUi(this);
34
    /* Initialisation des variables */
35
    m_localDebug = 0;
36
    
37
    /* Chargement langue */
38
    createLangMenu();
39
    QString locale = QLocale::system().name();
40
    m_qtTranslator.load("qt_" + locale,
41
                        QLibraryInfo::location(QLibraryInfo::TranslationsPath));
42
    abeApp->installTranslator(&m_qtTranslator);
43
    m_myAppTranslator.load(abeApp->applicationName() +"_"+ locale, "lang");
44
    abeApp->installTranslator(&m_myAppTranslator);
45
    
46
    m_nam = abeApp->getAbeNetworkAccessManager();
47
    connect(m_nam,SIGNAL(ssoAuthStatus(int)),this,SLOT(slotSSOStatusChanged(int)),Qt::UniqueConnection);
48
    
49
    
50
    /* La boite à propos, même en version V1, n'est pas une lib externe, je ne l'inclus donc pas pour l'instant */
51
    
52
    /* Gestion du mode tablette automatique */
53
#ifdef __ABULEDUTABLETTEV1__MODE__
54
    ui->menuBar->hide();
55
    ui->mainToolBar->hide();
56
    ui->statusBar->hide();
57
#else
58
    /*On centre la fenetre sur l'ecran de l'utilisateur et on lui met un titre */
59
    QDesktopWidget *widget = QApplication::desktop();
60
    int desktop_width = widget->width();
61
    int desktop_height = widget->height();
62
    this->move((desktop_width-this->width())/2, (desktop_height-this->height())/2);
63
    setTitle(abeApp->getAbeNetworkAccessManager()->abeSSOAuthenticationStatus());
64
#endif
65

  
66

  
67
    // create the socket and connect various of its signals
68
    socket = new QLocalSocket( this );
69
    connect( socket, SIGNAL(connected()), SLOT(socketConnected()) );
70
    connect( socket, SIGNAL(disconnected()), SLOT(socketConnectionClosed()) );
71
    connect( socket, SIGNAL(readyRead()), SLOT(socketReadyRead()) );
72
    connect( socket, SIGNAL(error(QLocalSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError)) );
73

  
74
    // create the STREAM socket and connect various of its signals
75
    stream_socket = new QTcpSocket( this );
76
    connect( stream_socket , SIGNAL(connected()), SLOT(Stream_socketConnected()) );
77
    connect( stream_socket , SIGNAL(disconnected()), SLOT(Stream_socketConnectionClosed()) );
78
    connect( stream_socket , SIGNAL(readyRead()), SLOT(socketReadyRead()) );
79
    connect( stream_socket , SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError)) );
80

  
81
    // connect to the server
82
    strcpy (&Output_String[0], "Trying to connect to the server ");
83
    ui->textBrowser->append(Output_String);
84
    socket->connectToServer("/var/run/clamav/clamd.ctl");
85
    //Get ClamAv Version
86
    sendStringToServer("VERSION");
87

  
88
    files_to_scan << "/tmp/devis_cde_facture_20130311.pdf" << "/tmp/Virus.Win32.Highway.a.zip";
89

  
90
    it = files_to_scan.begin();
91
    scanninginprogress = 1;
92
    totalvirusfound = 0;
93
    totalfilesscanned = 0;
94
    totalwarnings = 0;
95
    ui->textBrowser->append( "Start scanning..." );
96
    sendStringToServer("STREAM");
97
}
98

  
99
UtilitaireMainWindow::~UtilitaireMainWindow()
100
{
101
    delete ui;
102
}
103

  
104
void UtilitaireMainWindow::createLangMenu()
105
{
106
    QAction* actionLangueEn = new QAction(trUtf8("English"),this);
107
    actionLangueEn->setObjectName("en");
108
    connect(actionLangueEn, SIGNAL(triggered()), this, SLOT(slotChangeLang()),Qt::UniqueConnection);
109
    ui->menuLangues->addAction(actionLangueEn);
110
    
111
    QAction* actionLangueFr = new QAction(trUtf8("Français"),this);
112
    actionLangueFr->setObjectName("fr");
113
    connect(actionLangueFr, SIGNAL(triggered()), this, SLOT(slotChangeLang()),Qt::UniqueConnection);
114
    ui->menuLangues->addAction(actionLangueFr);
115
    
116
    /* Décommenter pour ajouter une ligne au menu Langues
117
    QAction* actionLangueEs = new QAction(trUtf8("Español"),this);
118
    actionLangueEs->setObjectName("es");
119
    connect(actionLangueEs, SIGNAL(triggered()), this, SLOT(slotChangeLangue()),Qt::UniqueConnection);
120
    ui->menuLangues->addAction(actionLangueEs); */
121
    
122
    /* Décommenter pour ajouter une ligne au menu Langues
123
    QAction* actionLangueDe = new QAction(trUtf8("Deutsche"),this);
124
    actionLangueDe->setObjectName("de");
125
    connect(actionLangueDe, SIGNAL(triggered()), this, SLOT(slotChangeLangue()),Qt::UniqueConnection);
126
    ui->menuLangues->addAction(actionLangueDe); */
127
    
128
    /* Décommenter pour ajouter une ligne au menu Langues
129
    QAction* actionLangueIt = new QAction(trUtf8("Italiano"),this);
130
    actionLangueIt->setObjectName("it");
131
    connect(actionLangueIt, SIGNAL(triggered()), this, SLOT(slotChangeLangue()),Qt::UniqueConnection);
132
    ui->menuLangues->addAction(actionLangueIt); */
133
    
134
    /* Décommenter pour ajouter une ligne au menu Langues
135
    QAction* actionLangueAr = new QAction(trUtf8("عربي"),this);
136
    actionLangueAr->setObjectName("ar");
137
    connect(actionLangueAr, SIGNAL(triggered()), this, SLOT(slotChangeLangue()),Qt::UniqueConnection);
138
    ui->menuLangues->addAction(actionLangueAr); */
139
}
140

  
141
void UtilitaireMainWindow::slotSessionAuthenticated(bool enable)
142
{
143
    if(enable)
144
    {
145
        m_nam->abeSSOLogin();
146
    }
147
    show();
148
    connect(m_nam, SIGNAL(ssoAuthStatus(int)), this,SLOT(setTitle(int)),Qt::UniqueConnection);
149
}
150

  
151
void UtilitaireMainWindow::slotChangeLang()
152
{
153
    QString lang = sender()->objectName();
154
    abeApp->removeTranslator(&m_qtTranslator);
155
    abeApp->removeTranslator(&m_myAppTranslator);
156
    
157
    m_qtTranslator.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
158
    abeApp->installTranslator(&m_qtTranslator);
159
    
160
    m_myAppTranslator.load(abeApp->applicationName() + "_" + lang, "lang");
161
    abeApp->installTranslator(&m_myAppTranslator);
162
    ui->retranslateUi(this);
163
}
164

  
165
void UtilitaireMainWindow::setTitle(int authStatus)
166
{
167
    QString title = abeApp->getAbeApplicationLongName();
168
    if (authStatus == 1)
169
    {
170
        title.append(" -- "+abeApp->getAbeNetworkAccessManager()->abeGetSSOLogin());
171
    }
172
    setWindowTitle(title);
173
}
174

  
175
void UtilitaireMainWindow::slotSSOStatusChanged(int code)
176
{
177
    /* Insérez ici le code que vous voulez concernant la modification d'état de l'authentification
178
       code = -1 (erreur d'authentification), 0 (on ne sait pas, jamais tenté), ou 1 (authentifié) */
179
    setTitle(code);
180
}
181

  
182
void UtilitaireMainWindow::on_action_Ouvrir_triggered()
183
{
184
    /* Écrivez ici le code à exécuter au clic sur l'entrée de menu "Fichier - Ouvrir" */
185
}
186

  
187
void UtilitaireMainWindow::on_action_Sauvegarder_triggered()
188
{
189
    /* Écrivez ici le code à exécuter au clic sur l'entrée de menu "Fichier - Sauvegarder" */
190
}
191

  
192
void UtilitaireMainWindow::on_actionQuitter_triggered()
193
{
194
    close();
195
}
196

  
197
void UtilitaireMainWindow::on_action_Authentification_triggered()
198
{
199
    m_nam->abeSSOLogout();
200
    m_nam->abeSSOLogin();
201
}
202

  
203
void UtilitaireMainWindow::showEvent ( QShowEvent * event )
204
{
205
#ifdef __ABULEDUTABLETTEV1__MODE__
206
    showFullScreen();
207
#else
208
    showNormal();
209
#endif
210
}
211

  
212

  
213
void UtilitaireMainWindow::socketConnected()
214
{
215
    ui->textBrowser->append("Connected to ClamAV local server");
216

  
217
//    sprintf (&Output_String[0], "Opening STREAM port %hu....", clamav_stream_port);
218
//    ui->textBrowser->append( Output_String );
219

  
220
//    stream_socket->connectToServer("/var/run/clamav/clamd.ctl");
221
}
222

  
223
void UtilitaireMainWindow::socketConnectionClosed()
224
{
225
    ui->textBrowser->append("Connection closed by the ClamAV server");
226
    if (scanninginprogress == 1)
227
    {
228
        ui->textBrowser->append("Opening new STREM...");
229
        socket->connectToServer("/var/run/clamav/clamd.ctl");
230
        sendStringToServer("STREAM");
231
    }
232
}
233

  
234
void UtilitaireMainWindow::socketReadyRead()
235
{
236
    // read from the server
237
    while ( socket->canReadLine() ) {
238
        Socket_Read_Line = socket->readLine();
239

  
240
        if (Socket_Read_Line.startsWith("PORT") != 0)
241
        {
242
            clamav_stream_port = Socket_Read_Line.mid(5).toInt();
243
            // connect to the STREAM server
244
            sprintf (&Output_String[0], "Opening STREAM port %hu....", clamav_stream_port);
245
            ui->textBrowser->append( Output_String );
246
            stream_socket->connectToHost("localhost", clamav_stream_port );
247
            ui->textBrowser->append( Socket_Read_Line );
248
        }
249

  
250

  
251
        else if (Socket_Read_Line.startsWith("FOUND") != 0)
252
        {
253
            //Clamd --> A VIRUS FOUND
254
            totalvirusfound++;
255
            ui->textBrowser->append( Socket_Read_Line );
256
            scan_next_file();
257
        }
258
        else if (Socket_Read_Line.startsWith("OK") != 0)
259
        {
260
            //Clamd --> NO VIRUS FOUND
261
            ui->textBrowser->append(Socket_Read_Line);
262
            scan_next_file();
263
        }
264
        else if (Socket_Read_Line.startsWith("ClamAV") != 0)
265
        {
266
            ui->textBrowser->append(Socket_Read_Line);
267
        }
268
        else
269
        {
270
            ui->textBrowser->append(Socket_Read_Line);
271
        }
272
    }
273

  
274
}
275

  
276
void UtilitaireMainWindow::socketError(QAbstractSocket::SocketError e)
277
{
278
    ui->textBrowser->append( trUtf8("Error number %1 occurred\n").arg(e) );
279
}
280

  
281
void UtilitaireMainWindow::Stream_socketConnected()
282
{
283
    if (! files_to_scan.empty())
284
    {
285
        FileToScan = files_to_scan.takeFirst();
286
        if ( !FileToScan.isEmpty() )
287
        {
288
            sendFileToServer(FileToScan);
289
        }
290
    }
291
    else
292
    {
293
        scanninginprogress = 0;
294
        ui->textBrowser->append( "Scan terminated" );
295
    }
296
}
297

  
298
void UtilitaireMainWindow::Stream_socketConnectionClosed()
299
{
300
    //STREAM has been closed on end of file to start scanning it
301
}
302

  
303
void UtilitaireMainWindow::sendStringToServer(const QString &stringtosend)
304
{
305
    // write to the server
306
    QTextStream os(socket);
307
    os << stringtosend << "\n";
308
}
309

  
310
void UtilitaireMainWindow::sendFileToServer(const QString &file_to_scan)
311
{
312
    char buffer[1500];
313
    int nbytes;
314
    int file_size;
315
    int stream_percent;
316

  
317
    sprintf (&Output_String[0], "Scanning...");
318
    ui->textBrowser->append(Output_String);
319

  
320
    ui->textBrowser->append(file_to_scan );
321
    totalfilesscanned++;
322
    QFile file(file_to_scan);
323
    if (file.open (QIODevice::ReadOnly))
324
    {
325
        file_size = (int)file.size();
326

  
327
        sprintf (&Output_String[0], "File size is %d", file_size);
328
        ui->textBrowser->append(Output_String);
329

  
330
        stream_percent = 0;
331
//        streamprogress->setTotalSteps (file_size);
332
        while (((nbytes = file.read(buffer, sizeof(buffer))) > 0) && (file_size <= max_stream_size))
333
        {
334
            stream_percent += nbytes;
335
            if (stream_socket->isOpen())
336
            {
337
                if (stream_socket->write(buffer, sizeof(buffer)) == -1)
338
                {
339
                    ui->textBrowser->append("Unexpected Error: writeBlock error");
340
                }
341
//                streamprogress->setProgress (stream_percent );
342
            }
343
            else
344
                ui->textBrowser->append("Unexpected Error: stream_socket is closed");
345
        }
346
        if (file_size > max_stream_size)
347
        {
348
            totalwarnings++;
349
            ui->textBrowser->append("Warning: the above file is too large and could not be scanned (max_stream_size).");
350
        }
351
        file.close();
352
    }
353
    if (stream_socket->state() == QLocalSocket::ConnectedState)
354
        stream_socket->close(); //close socket to perform scan
355
    else
356
        ui->textBrowser->append("Unexpected Error: the STREAM socket has been already closed!");
357
}
358

  
359
void UtilitaireMainWindow::scan_next_file()
360
{
361
//    streamprogress->setProgress ( 0 );
362
    if (scanninginprogress == 1)
363
    {
364
        ++it;
365
        if (it == files_to_scan.end() )
366
        {
367
            if (totalvirusfound > 0)
368
            {
369
                sprintf (&Output_String[0], "*** ClamAV found (%d) virus(es) - %d file(s) scanned ***", totalvirusfound, totalfilesscanned );
370
                ui->textBrowser->append( Output_String );
371
            }
372
            else
373
            {
374
                sprintf (&Output_String[0], "*** No virus found - %d file(s) scanned ***", totalfilesscanned );
375
                ui->textBrowser->append( Output_String );
376
            }
377
            if (totalwarnings > 0)
378
            {
379
                sprintf (&Output_String[0], "*** Total warning(s) %d ***", totalwarnings );
380
                ui->textBrowser->append( Output_String );
381
            }
382
            totalwarnings = 0;
383
            totalfilesscanned = 0;
384
            totalvirusfound = 0;
385
            scanninginprogress = 0;
386
        }
387
    }
388
}
utilitairemainwindow.h
1
/** Classe de base pour les mainwindows des logiciels AbulEdu (ryxeo-antivirus)
2
  *
3
  * @see https://redmine.ryxeo.com/projects/ryxeo-antivirus
4
  * @author 2013 Eric Seigne <eric.seigne@ryxeo.com
5
  * 
6
  * @see https://redmine.ryxeo.com/projects/ryxeo/wiki/UtilitaireMainWindow
7
  * @author 2012 Philippe <philippe.cadaugade@ryxeo.com>
8
  *
9
  * @see The GNU Public License (GPL)
10
  *
11
  * This program is free software; you can redistribute it and/or modify
12
  * it under the terms of the GNU General Public License as published by
13
  * the Free Software Foundation; either version 2 of the License, or
14
  * (at your option) any later version.
15
  *
16
  * This program is distributed in the hope that it will be useful, but
17
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18
  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19
  * for more details.
20
  *
21
  * You should have received a copy of the GNU General Public License along
22
  * with this program; if not, write to the Free Software Foundation, Inc.,
23
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
  */
25

  
26
#ifndef UTILITAIREMAINWINDOW_H
27
#define UTILITAIREMAINWINDOW_H
28

  
29
/* Inclusion de classes Qt */
30
#include <QMainWindow>
31
#include <QDebug>
32
#include <QLocalSocket>
33
#include <QTcpSocket>
34
#include <QAbstractSocket>
35

  
36
#include <QFileDialog>
37

  
38
/* Inclusion de classes AbulEdu */
39
#include "abuleduapplicationv1.h"
40

  
41
#define max_stream_size 10000000 //this value defines the maximum files size to be scanned and should be equal to the StreamMaxLength parameter in the clamd.conf file.
42

  
43
namespace Ui {
44
class UtilitaireMainWindow;
45
}
46

  
47
class UtilitaireMainWindow : public QMainWindow
48
{
49
    Q_OBJECT
50
    
51
public:
52
    /* Méthodes */
53
    /** Constructeur */
54
    explicit UtilitaireMainWindow(QWidget *parent = 0);
55
    
56
    /** Destructeur virtuel pour cause d'objectif de polymorphisme */
57
    virtual ~UtilitaireMainWindow();
58
    
59
protected:
60
    /* Attributs */
61
    /** Variable membre qui permet de contrôler l'affichage des qDebug */
62
    bool                     m_localDebug;
63
    
64
    /* Méthodes */
65
    /** Crée dans le menu Langues de l'interface graphique une entrée pour les langues désirées
66
      * Seuls l'anglais et le français sont présents au départ
67
      * Quelques langues sont prêtes à ajouter, en décommentant le bloc qui leur correspond
68
      * Vous pouvez ajouter d'autres langues sur le même modèle */
69
    virtual void createLangMenu();
70
    
71
private:
72
    /** Gestion de l'affichage de la fenetre pour les tablettes */
73
    void showEvent ( QShowEvent * event );
74
    
75
    /* Attributs */
76
    /** Pointeur vers l'interface graphique */
77
    Ui::UtilitaireMainWindow* ui;
78
    
79
    /** QTranslator destiné aux traductions Qt System */
80
    QTranslator              m_qtTranslator;
81
    
82
    /** QTranslator destiné aux traductions spécifiques du logiciel */
83
    QTranslator              m_myAppTranslator;
84
    
85
    /** Pointeur vers un l'AbulEduNetworkAccessManagerV1 de l'application, assignation dans le constructeur */
86
    AbulEduNetworkAccessManagerV1 *m_nam;
87

  
88

  
89
    int totalfilesscanned;
90
    int totalvirusfound;
91
    int totalwarnings;
92
    int scanninginprogress;
93
    QString ClamAV_host;
94
    QString FileToScan;
95
    QStringList files_to_scan;
96
    QStringList::Iterator it;
97
    QLocalSocket *socket;
98
    QTcpSocket *stream_socket;
99
    QLineEdit *inputText;
100
    QString Socket_Read_Line;
101
    char Output_String[512];
102
    const QString host;
103
    int clamav_main_port;
104
    int clamav_stream_port;
105
    
106
public slots:
107
    /** Affiche l'UtilitaireMainWindow après éventuellement demande d'authentification
108
      * Connecté dans la méthode setMainWindow() de l'AbulEduSplashScreenV1 */
109
    void slotSessionAuthenticated(bool enable);
110
    
111
private slots:
112
    /** Opère le changement de langue désiré
113
      * Connecté aux entrées du menu Langues */
114
    void slotChangeLang();
115
    
116
    /** Actualise le nom de la fenêtre en fonction du nom du logiciel, du nom de l'exercice et du nom de l'utilisateur */
117
    void setTitle(int authStatus);
118
    
119
    /** Permet de gerer les changement d'états d'authentification sso
120
      * @param code est l'entier envoyé dans le signal ssoAuthStatus(int) de l'AbulEduNetworkAccessManagerV1
121
      * avec lequel ce slot est connecté */
122
    void slotSSOStatusChanged(int code);
123
    
124
    /** Code à exécuter au clic sur l'entrée de menu Fichier - Ouvrir */
125
    void on_action_Ouvrir_triggered();
126
    
127
    /** Code à exécuter au clic sur l'entrée de menu "Fichier - Sauvegarder" */
128
    void on_action_Sauvegarder_triggered();
129
    
130
    /** Code à exécuter au clic sur l'entrée de menu "Fichier - Quitter" */
131
    void on_actionQuitter_triggered();
132
    
133
    /** Code à exécuter au clic sur l'entrée de menu "Utilisateur - Authentification" */
134
    void on_action_Authentification_triggered();
135

  
136
    void socketConnected();
137
    void socketConnectionClosed();
138
    void socketReadyRead();
139
    void socketError(QAbstractSocket::SocketError e);
140

  
141
    void Stream_socketConnected();
142
    void Stream_socketConnectionClosed();
143

  
144
    void sendStringToServer(const QString &stringtosend);
145
    void sendFileToServer(const QString &file_to_scan);
146
    void scan_next_file();
147
};
148

  
149
#endif // UTILITAIREMAINWINDOW_H
150

  
utilitairemainwindow.ui
1
<?xml version="1.0" encoding="UTF-8"?>
2
<ui version="4.0">
3
 <class>UtilitaireMainWindow</class>
4
 <widget class="QMainWindow" name="UtilitaireMainWindow">
5
  <property name="geometry">
6
   <rect>
7
    <x>0</x>
8
    <y>0</y>
9
    <width>1024</width>
10
    <height>550</height>
11
   </rect>
12
  </property>
13
  <property name="windowTitle">
14
   <string>UtilitaireMainWindow</string>
15
  </property>
16
  <widget class="QWidget" name="centralWidget">
17
   <layout class="QGridLayout" name="gridLayout">
18
    <item row="0" column="0">
19
     <widget class="QTextBrowser" name="textBrowser"/>
20
    </item>
21
   </layout>
22
  </widget>
23
  <widget class="QMenuBar" name="menuBar">
24
   <property name="geometry">
25
    <rect>
26
     <x>0</x>
27
     <y>0</y>
28
     <width>1024</width>
29
     <height>25</height>
30
    </rect>
31
   </property>
32
   <widget class="QMenu" name="menuFichier">
33
    <property name="title">
34
     <string>&amp;Fichier</string>
35
    </property>
36
    <addaction name="action_Ouvrir"/>
37
    <addaction name="action_Sauvegarder"/>
38
    <addaction name="separator"/>
39
    <addaction name="actionQuitter"/>
40
   </widget>
41
   <widget class="QMenu" name="menuLangues">
42
    <property name="title">
43
     <string>&amp;Langues</string>
44
    </property>
45
   </widget>
46
   <widget class="QMenu" name="menuUtilisateurs">
47
    <property name="title">
48
     <string>&amp;Utilisateur</string>
49
    </property>
50
    <addaction name="action_Authentification"/>
51
   </widget>
52
   <addaction name="menuFichier"/>
53
   <addaction name="menuLangues"/>
54
   <addaction name="menuUtilisateurs"/>
55
  </widget>
56
  <widget class="QToolBar" name="mainToolBar">
57
   <attribute name="toolBarArea">
58
    <enum>TopToolBarArea</enum>
59
   </attribute>
60
   <attribute name="toolBarBreak">
61
    <bool>false</bool>
62
   </attribute>
63
  </widget>
64
  <widget class="QStatusBar" name="statusBar"/>
65
  <action name="action_Ouvrir">
66
   <property name="text">
67
    <string>&amp;Ouvrir</string>
68
   </property>
69
   <property name="shortcut">
70
    <string>Ctrl+O</string>
71
   </property>
72
  </action>
73
  <action name="action_Sauvegarder">
74
   <property name="text">
75
    <string>&amp;Sauvegarder</string>
76
   </property>
77
   <property name="shortcut">
78
    <string>Ctrl+E</string>
79
   </property>
80
  </action>
81
  <action name="actionQuitter">
82
   <property name="text">
83
    <string>&amp;Quitter</string>
84
   </property>
85
   <property name="shortcut">
86
    <string>Ctrl+Q</string>
87
   </property>
88
  </action>
89
  <action name="action_Authentification">
90
   <property name="text">
91
    <string>&amp;Authentification</string>
92
   </property>
93
  </action>
94
 </widget>
95
 <layoutdefault spacing="6" margin="11"/>
96
 <resources/>
97
 <connections/>
98
</ui>
version.h
1
#ifndef VERSION_H
2
#define VERSION_H
3

  
4
#define VER_FILEVERSION             0,1,0,0
5
#define VER_FILEVERSION_STR         "0.1.0\0"
6

  
7
#define VER_PRODUCTVERSION          0,1,0,0
8
#define VER_PRODUCTVERSION_STR      "0.1.0\0"
9

  
10
#define VER_COMPANYNAME_STR         "entreprise"
11
#define VER_FILEDESCRIPTION_STR     "AbulEdu -- ryxeo-antivirus"
12
#define VER_INTERNALNAME_STR        "ryxeo-antivirus"
13
#define VER_LEGALCOPYRIGHT_STR      "Copyright (c) 2013"
14
#define VER_LEGALTRADEMARKS1_STR    "All Rights Reserved"
15
#define VER_LEGALTRADEMARKS2_STR    "License GNU/GPL v3"
16
#define VER_ORIGINALFILENAME_STR    "ryxeo-antivirus.exe"
17
#define VER_PRODUCTNAME_STR         "AbulEdu -- ryxeo-antivirus"
18

  
19
#define VER_COMPANYDOMAIN_STR       "abuledu.org"
20

  
21
#endif // VERSION_H

Formats disponibles : Unified diff

Redmine Appliance - Powered by TurnKey Linux