[elvystrac] r1923 - make sures that downloaded files are OK via md5 checksum

  • From: elvys@xxxxxxxxxxxxxxxxxxxxxx
  • To: elvystrac@xxxxxxxxxxxxx
  • Date: Sat, 27 Feb 2010 20:00:45 +0100

Author: JirkaH
Date: 2010-02-27 20:00:44 +0100 (Sat, 27 Feb 2010)
New Revision: 1923

Added:
   trunk/client/elvys-client/src/hasher.cpp
   trunk/client/elvys-client/src/hasher.h
Modified:
   trunk/client/elvys-client/src/Makefile
   trunk/client/elvys-client/src/documentmaintainer.cpp
   trunk/client/elvys-client/src/documentmaintainer.h
   trunk/client/elvys-client/src/filecachemaintainer.cpp
   trunk/client/elvys-client/src/filecachemaintainer.h
   trunk/client/elvys-client/src/http.cpp
   trunk/client/elvys-client/src/http.h
   trunk/client/elvys-client/src/src.pro
   trunk/client/elvys-client/src/statisticsdata.cpp
   trunk/client/elvys-client/src/videodocument.cpp
   trunk/client/elvys-client/src/videodocument.h
   trunk/client/elvys-client/src/xmldocumentparser.cpp
   trunk/client/elvys-client/src/xmldocumentparser.h
Log:
make sures that downloaded files are OK via md5 checksum


Modified: trunk/client/elvys-client/src/Makefile
===================================================================
--- trunk/client/elvys-client/src/Makefile      2010-02-27 15:34:39 UTC (rev 
1922)
+++ trunk/client/elvys-client/src/Makefile      2010-02-27 19:00:44 UTC (rev 
1923)
@@ -1,6 +1,6 @@
 #############################################################################
 # Makefile for building: ../bin/elvys-client
-# Generated by qmake (2.01a) (Qt 4.5.3) on: Thu Feb 25 13:56:05 2010
+# Generated by qmake (2.01a) (Qt 4.5.3) on: Sat Feb 27 19:43:10 2010
 # Project:  src.pro
 # Template: app
 # Command: /usr/bin/qmake -spec /usr/share/qt4/mkspecs/linux-g++ -unix 
CONFIG+=release -o Makefile src.pro
@@ -13,10 +13,10 @@
 DEFINES       = -D_TTY_POSIX_ -DQT_SQL_LIB -DQT_XML_LIB -DQT_GUI_LIB 
-DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED
 CFLAGS        = -pipe -g -D_REENTRANT -Wall -W $(DEFINES)
 CXXFLAGS      = -pipe -g -D_REENTRANT -Wall -W $(DEFINES)
-INCPATH       = -I/usr/share/qt4/mkspecs/linux-g++ -I. 
-I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui 
-I/usr/include/qt4/QtXml -I/usr/include/qt4/QtSql -I/usr/include/qt4 
-I/usr/include/qt4/QtTest -Iserial -I/usr/include/XpdfRasterizer 
-I/usr/include/KDE -I.
+INCPATH       = -I/usr/share/qt4/mkspecs/linux-g++ -I. 
-I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui 
-I/usr/include/qt4/QtXml -I/usr/include/qt4/QtSql -I/usr/include/qt4 
-I/usr/include/qt4/QtTest -Iserial -Iqtlockedfile -I/usr/include/XpdfRasterizer 
-I/usr/include/KDE -I.
 LINK          = g++
 LFLAGS        = -Wl,-rpath,/usr/lib/qt4
-LIBS          = $(SUBLIBS)  -L/usr/lib/qt4 
-L../../XpdfRasterizer-3.02.14-linux/lib -L/usr/lib -lsqlite -lphonon 
-lXpdfRasterizer -lQtTest -L/usr/lib/qt4 -pthread -pthread -lQtSql 
-L/usr/lib/mysql -pthread -pthread -lQtXml -pthread -pthread -lQtGui 
-L/usr/X11R6/lib -pthread -lpng -lfreetype -lgobject-2.0 -lSM -lICE -pthread 
-pthread -lXrender -lXrandr -lXinerama -lfontconfig -lXext -lX11 -lQtNetwork 
-pthread -pthread -lQtCore -lz -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl 
-lpthread
+LIBS          = $(SUBLIBS)  -L/usr/lib/qt4 
-L../../XpdfRasterizer-3.02.14-linux/lib -L/usr/lib -lsqlite -lphonon 
-lXpdfRasterizer -lQtSolutions_LockedFile-2.4 -lQtTest -L/usr/lib/qt4 -pthread 
-pthread -lQtSql -L/usr/lib/mysql -pthread -pthread -lQtXml -pthread -pthread 
-lQtGui -L/usr/X11R6/lib -pthread -lpng -lfreetype -lgobject-2.0 -lSM -lICE 
-pthread -pthread -lXrender -lXrandr -lXinerama -lfontconfig -lXext -lX11 
-lQtNetwork -pthread -pthread -lQtCore -lz -lm -pthread -lgthread-2.0 -lrt 
-lglib-2.0 -ldl -lpthread
 AR            = ar cqs
 RANLIB        = 
 QMAKE         = /usr/bin/qmake
@@ -92,7 +92,8 @@
                pdfpresentationdocument.cpp \
                pdfpresentationviewer.cpp \
                pdfcommonviewer.cpp \
-               timestamper.cpp moc_elvys.cpp \
+               timestamper.cpp \
+               hasher.cpp moc_elvys.cpp \
                moc_pdfdocument.cpp \
                moc_pdffiller.cpp \
                moc_pdfviewer.cpp \
@@ -185,6 +186,7 @@
                pdfpresentationviewer.o \
                pdfcommonviewer.o \
                timestamper.o \
+               hasher.o \
                moc_elvys.o \
                moc_pdfdocument.o \
                moc_pdffiller.o \
@@ -339,7 +341,7 @@
 
 dist: 
        @$(CHK_DIR_EXISTS) .tmp/elvys-client1.0.0 || $(MKDIR) 
.tmp/elvys-client1.0.0 
-       $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/elvys-client1.0.0/ && 
$(COPY_FILE) --parents elvys.h pdfdocument.h pdffiller.h pdfviewer.h 
pdfzoomed.h constants.h pdfpage.h statictext.h xmllayoutparser.h 
xmldocumentparser.h appconfig.h screenshooter.h http.h dynamictext.h 
serial/posix_qextserialport.h serialcontrols.h serial/qextserialbase.h 
serial/qextserialport.h xmlappparser.h xmlabstractparser.h appmaintainer.h 
abstractmaintainer.h layoutmaintainer.h documentmaintainer.h document.h 
modechanger.h saver.h appconfigdata.h dummydocument.h page.h 
xmlstatisticswriter.h textdocument.h pageselector.h category.h panel.h 
categorymaintainerdoc.h categorymaintainerlayout.h xmlcatlayoutparser.h 
categorymanager.h xmlcatdocparser.h xmlpaneldocparser.h statisticevent.h 
statisticsdata.h statistics.h videodocument.h autodeleter.h 
xmlfilecacheparser.h filecachemaintainer.h logotabbar.h 
pdfpresentationdocument.h pdfpresentationviewer.h pdfcommonviewer.h 
timestamper.h .tmp/elvys-client1.0.0/
  && $(COPY_FILE) --parents application.qrc .tmp/elvys-client1.0.0/ && 
$(COPY_FILE) --parents main.cpp pdfdocument.cpp pdffiller.cpp pdfviewer.cpp 
pdfzoomed.cpp pdfpage.cpp xmllayoutparser.cpp elvys.cpp xmldocumentparser.cpp 
appconfig.cpp screenshooter.cpp http.cpp dynamictext.cpp statictext.cpp 
serial/posix_qextserialport.cpp serial/qextserialbase.cpp 
serial/qextserialport.cpp serialcontrols.cpp xmlappparser.cpp 
xmlabstractparser.cpp abstractmaintainer.cpp appmaintainer.cpp 
layoutmaintainer.cpp documentmaintainer.cpp modechanger.cpp saver.cpp 
appconfigdata.cpp dummydocument.cpp page.cpp statisticsdata.cpp 
xmlstatisticswriter.cpp textdocument.cpp category.cpp panel.cpp 
categorymaintainerdoc.cpp categorymaintainerlayout.cpp xmlcatlayoutparser.cpp 
categorymanager.cpp xmlcatdocparser.cpp xmlpaneldocparser.cpp 
statisticevent.cpp statistics.cpp videodocument.cpp autodeleter.cpp 
xmlfilecacheparser.cpp filecachemaintainer.cpp logotabbar.cpp 
pdfpresentationdocument.cpp pdfpresentatio
 nviewer.cpp pdfcommonviewer.cpp timestamper.cpp .tmp/elvys-client1.0.0/ && (cd 
`dirname .tmp/elvys-client1.0.0` && $(TAR) elvys-client1.0.0.tar 
elvys-client1.0.0 && $(COMPRESS) elvys-client1.0.0.tar) && $(MOVE) `dirname 
.tmp/elvys-client1.0.0`/elvys-client1.0.0.tar.gz . && $(DEL_FILE) -r 
.tmp/elvys-client1.0.0
+       $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/elvys-client1.0.0/ && 
$(COPY_FILE) --parents elvys.h pdfdocument.h pdffiller.h pdfviewer.h 
pdfzoomed.h constants.h pdfpage.h statictext.h xmllayoutparser.h 
xmldocumentparser.h appconfig.h screenshooter.h http.h dynamictext.h 
serial/posix_qextserialport.h serialcontrols.h serial/qextserialbase.h 
serial/qextserialport.h xmlappparser.h xmlabstractparser.h appmaintainer.h 
abstractmaintainer.h layoutmaintainer.h documentmaintainer.h document.h 
modechanger.h saver.h appconfigdata.h dummydocument.h page.h 
xmlstatisticswriter.h textdocument.h pageselector.h category.h panel.h 
categorymaintainerdoc.h categorymaintainerlayout.h xmlcatlayoutparser.h 
categorymanager.h xmlcatdocparser.h xmlpaneldocparser.h statisticevent.h 
statisticsdata.h statistics.h videodocument.h autodeleter.h 
xmlfilecacheparser.h filecachemaintainer.h logotabbar.h 
pdfpresentationdocument.h pdfpresentationviewer.h pdfcommonviewer.h 
timestamper.h hasher.h .tmp/elvys-cli
 ent1.0.0/ && $(COPY_FILE) --parents application.qrc .tmp/elvys-client1.0.0/ && 
$(COPY_FILE) --parents main.cpp pdfdocument.cpp pdffiller.cpp pdfviewer.cpp 
pdfzoomed.cpp pdfpage.cpp xmllayoutparser.cpp elvys.cpp xmldocumentparser.cpp 
appconfig.cpp screenshooter.cpp http.cpp dynamictext.cpp statictext.cpp 
serial/posix_qextserialport.cpp serial/qextserialbase.cpp 
serial/qextserialport.cpp serialcontrols.cpp xmlappparser.cpp 
xmlabstractparser.cpp abstractmaintainer.cpp appmaintainer.cpp 
layoutmaintainer.cpp documentmaintainer.cpp modechanger.cpp saver.cpp 
appconfigdata.cpp dummydocument.cpp page.cpp statisticsdata.cpp 
xmlstatisticswriter.cpp textdocument.cpp category.cpp panel.cpp 
categorymaintainerdoc.cpp categorymaintainerlayout.cpp xmlcatlayoutparser.cpp 
categorymanager.cpp xmlcatdocparser.cpp xmlpaneldocparser.cpp 
statisticevent.cpp statistics.cpp videodocument.cpp autodeleter.cpp 
xmlfilecacheparser.cpp filecachemaintainer.cpp logotabbar.cpp 
pdfpresentationdocument.cpp pdfpr
 esentationviewer.cpp pdfcommonviewer.cpp timestamper.cpp hasher.cpp 
.tmp/elvys-client1.0.0/ && (cd `dirname .tmp/elvys-client1.0.0` && $(TAR) 
elvys-client1.0.0.tar elvys-client1.0.0 && $(COMPRESS) elvys-client1.0.0.tar) 
&& $(MOVE) `dirname .tmp/elvys-client1.0.0`/elvys-client1.0.0.tar.gz . && 
$(DEL_FILE) -r .tmp/elvys-client1.0.0
 
 
 clean:compiler_clean 
@@ -366,6 +368,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                xmlappparser.h \
                filecachemaintainer.h \
@@ -461,11 +464,13 @@
 moc_screenshooter.cpp: http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                screenshooter.h
        /usr/bin/moc $(DEFINES) $(INCPATH) screenshooter.h -o 
moc_screenshooter.cpp
 
 moc_http.cpp: appconfig.h \
                appconfigdata.h \
+               hasher.h \
                http.h
        /usr/bin/moc $(DEFINES) $(INCPATH) http.h -o moc_http.cpp
 
@@ -487,6 +492,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                xmlappparser.h \
                appmaintainer.h
@@ -495,6 +501,7 @@
 moc_abstractmaintainer.cpp: http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                abstractmaintainer.h
        /usr/bin/moc $(DEFINES) $(INCPATH) abstractmaintainer.h -o 
moc_abstractmaintainer.cpp
@@ -503,6 +510,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                modechanger.h \
                layoutmaintainer.h
@@ -512,6 +520,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                abstractmaintainer.h \
                xmlabstractparser.h \
                documentmaintainer.h
@@ -542,6 +551,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                modechanger.h \
                xmlpaneldocparser.h \
@@ -570,6 +580,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                abstractmaintainer.h \
                xmlabstractparser.h \
                document.h \
@@ -593,6 +604,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                xmlcatdocparser.h \
                constants.h \
@@ -603,6 +615,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                xmlcatlayoutparser.h \
                constants.h \
@@ -619,6 +632,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                xmlcatdocparser.h \
                constants.h \
@@ -663,6 +677,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                statisticsdata.h
        /usr/bin/moc $(DEFINES) $(INCPATH) statisticsdata.h -o 
moc_statisticsdata.cpp
 
@@ -672,6 +687,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                statistics.h
        /usr/bin/moc $(DEFINES) $(INCPATH) statistics.h -o moc_statistics.cpp
 
@@ -694,6 +710,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                xmlfilecacheparser.h \
                constants.h \
@@ -770,6 +787,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                xmlappparser.h \
                filecachemaintainer.h \
@@ -880,6 +898,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                xmlappparser.h \
                filecachemaintainer.h \
@@ -939,12 +958,14 @@
 screenshooter.o: screenshooter.cpp screenshooter.h \
                http.h \
                appconfig.h \
-               appconfigdata.h
+               appconfigdata.h \
+               hasher.h
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o screenshooter.o screenshooter.cpp
 
 http.o: http.cpp http.h \
                appconfig.h \
-               appconfigdata.h
+               appconfigdata.h \
+               hasher.h
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o http.o http.cpp
 
 dynamictext.o: dynamictext.cpp dynamictext.h \
@@ -993,6 +1014,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o abstractmaintainer.o 
abstractmaintainer.cpp
 
@@ -1001,6 +1023,7 @@
                appmaintainer.h \
                abstractmaintainer.h \
                http.h \
+               hasher.h \
                xmlabstractparser.h \
                xmlappparser.h
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o appmaintainer.o appmaintainer.cpp
@@ -1010,6 +1033,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                modechanger.h \
                xmllayoutparser.h \
@@ -1033,6 +1057,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                abstractmaintainer.h \
                xmlabstractparser.h \
                xmldocumentparser.h \
@@ -1085,6 +1110,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                constants.h
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o statisticsdata.o statisticsdata.cpp
 
@@ -1101,6 +1127,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                modechanger.h \
                xmlpaneldocparser.h \
@@ -1132,6 +1159,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                abstractmaintainer.h \
                xmlabstractparser.h \
                document.h \
@@ -1155,6 +1183,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                xmlcatdocparser.h \
                constants.h
@@ -1165,6 +1194,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                xmlcatlayoutparser.h \
                constants.h
@@ -1181,6 +1211,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                xmlcatdocparser.h \
                constants.h \
@@ -1228,7 +1259,8 @@
                statisticevent.h \
                http.h \
                appconfig.h \
-               appconfigdata.h
+               appconfigdata.h \
+               hasher.h
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o statistics.o statistics.cpp
 
 videodocument.o: videodocument.cpp videodocument.h \
@@ -1251,6 +1283,7 @@
                http.h \
                appconfig.h \
                appconfigdata.h \
+               hasher.h \
                xmlabstractparser.h \
                xmlfilecacheparser.h \
                constants.h \
@@ -1300,6 +1333,9 @@
 timestamper.o: timestamper.cpp timestamper.h
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o timestamper.o timestamper.cpp
 
+hasher.o: hasher.cpp hasher.h
+       $(CXX) -c $(CXXFLAGS) $(INCPATH) -o hasher.o hasher.cpp
+
 moc_elvys.o: moc_elvys.cpp 
        $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_elvys.o moc_elvys.cpp
 

Modified: trunk/client/elvys-client/src/documentmaintainer.cpp
===================================================================
--- trunk/client/elvys-client/src/documentmaintainer.cpp        2010-02-27 
15:34:39 UTC (rev 1922)
+++ trunk/client/elvys-client/src/documentmaintainer.cpp        2010-02-27 
19:00:44 UTC (rev 1923)
@@ -31,8 +31,8 @@
 
        connect(parser, SIGNAL(readFailed()), this, SLOT(deleteTempFile()));    
 
-       connect(&docDownloader, SIGNAL(gotDocument(QString &, QString &, 
QString &)), this, SLOT(newDownloadableDocument(QString &, QString &, QString& 
)));
-       connect(&docDownloader, SIGNAL(gotDocument(QString &, QString &, 
QString &)), this, SLOT(downloadCompleteEventHandler(QString &, QString &, 
QString &)));
+       connect(&docDownloader, SIGNAL(gotDocument(QString &, QString &, 
QString &, QString &)), this, SLOT(newDownloadableDocument(QString &, QString 
&, QString&, QString & )));
+       connect(&docDownloader, SIGNAL(gotDocument(QString &, QString &, 
QString &, QString &)), this, SLOT(downloadCompleteEventHandler(QString &, 
QString &, QString &, QString &)));
        connect(this, SIGNAL(downloadStartEvent(int)), this, 
SLOT(downloadStartEventHandler(int)));
        commonInit();
 }
@@ -174,46 +174,47 @@
        }
 }
 
-void DocumentMaintainer::newPDFPresentation(QString & to_id, QString & docId, 
QString & name) {
-       newDownloadableDocument<PDFPresentationDocument>(to_id, docId, name);
+void DocumentMaintainer::newPDFPresentation(QString & to_id, QString & docId, 
QString & name, QString & hash) {
+       newDownloadableDocument<PDFPresentationDocument>(to_id, docId, name, 
hash);
 }
 
-void DocumentMaintainer::newPDFDocument(QString & to_id, QString & docId, 
QString & name) {
-       newDownloadableDocument<PDFDocument>(to_id, docId, name);
+void DocumentMaintainer::newPDFDocument(QString & to_id, QString & docId, 
QString & name, QString & hash) {
+       newDownloadableDocument<PDFDocument>(to_id, docId, name, hash);
 }
 
-void DocumentMaintainer::newVideoDocument(QString & to_id, QString & docId, 
QString & name) {
-       newDownloadableDocument<VideoDocument>(to_id, docId, name);
+void DocumentMaintainer::newVideoDocument(QString & to_id, QString & docId, 
QString & name, QString & hash) {
+       newDownloadableDocument<VideoDocument>(to_id, docId, name, hash);
 }
 
-void DocumentMaintainer::newDownloadableDocument(QString & to_id, QString & 
docId, QString & name) {
+void DocumentMaintainer::newDownloadableDocument(QString & to_id, QString & 
docId, QString & name, QString & hash) {
        Document * doc = findChild<Document *>(to_id);
        PDFPresentationDocument * pdfPresentation;
        PDFDocument * pdfDoc;
        VideoDocument * videoDoc;
 
        if ( (pdfDoc = qobject_cast<PDFDocument *>(doc)) != 0) {
-               newDownloadableDocument<PDFDocument>(to_id, docId, name);
+               newDownloadableDocument<PDFDocument>(to_id, docId, name, hash);
        } else if ( (videoDoc = qobject_cast<VideoDocument *>(doc)) != 0) {
-               newDownloadableDocument<VideoDocument>(to_id, docId, name);
+               newDownloadableDocument<VideoDocument>(to_id, docId, name, 
hash);
        } else if ( (pdfPresentation = qobject_cast<PDFPresentationDocument 
*>(doc)) != 0) {
-               newDownloadableDocument<PDFPresentationDocument>(to_id, docId, 
name);
+               newDownloadableDocument<PDFPresentationDocument>(to_id, docId, 
name, hash);
        }
 
 }
 
-template <class T> void DocumentMaintainer::newDownloadableDocument(QString & 
to_id, QString & docId, QString & name) {
+template <class T> void DocumentMaintainer::newDownloadableDocument(QString & 
to_id, QString & docId, QString & name, QString & hash) {
        Document * doc = NULL;
        T * downloadableDoc;
+       QString fileN = AppConfig::getInstance()->getLocalDataDir()+ name;
 
        if ( (downloadableDoc = panel->findChild<T *>(to_id)) == NULL ) { // 
same object type doesn't exist yet
 
                doc = panel->findChild<Document *>(to_id);
                Q_ASSERT(doc != NULL);
-               if ( QFile::exists(AppConfig::getInstance()->getLocalDataDir()+ 
name) ) {
-                       if (docDownloader.isTransfering(name)) { //we are 
downlaoding this document, just wait for it
-                               return;
-                       }
+               if (docDownloader.isTransfering(name)) { //we are downlaoding 
this document, just wait for it
+                       return;
+               }
+               if ( QFile::exists(fileN) && Hasher::md5Hash(fileN) == hash) {
                        downloadableDoc = new T(doc, docId.toInt());
                        connect(downloadableDoc, 
SIGNAL(exhibitCompleteEvent(int,int)), this, 
SLOT(exhibitCompleteEventHandler(int,int)));
                        connect(downloadableDoc, SIGNAL(zoomEvent(int, int)), 
panel, SLOT(zoomEventHandler(int, int)));
@@ -222,11 +223,21 @@
                        emit exhibitStartEvent(docId.toInt() , to_id.toInt());  
                
                        delete doc;
                } else {
+                       if ( QFile::exists(fileN) ) { //it means that the hash 
is wrong
+                               QtLockedFile * file = new QtLockedFile(fileN);
+                               if (! file->isLocked()) {
+                                       QFile::remove(fileN);
+                               } else {
+                                       qDebug() << "file is locked!";
+                               }
+                               delete file;
+                       }
                        emit downloadStartEvent(docId.toInt());
-                       docDownloader.getDocument(to_id, docId, name);
+                       docDownloader.getDocument(to_id, docId, name, hash);
                }
-       } else if ( downloadableDoc->getName() != name ) {
-               if ( QFile::exists(AppConfig::getInstance()->getLocalDataDir()+ 
name) ) {
+       } else if ( downloadableDoc->getName() != name ) {              
+               qWarning() << "hash debug" << hash << Hasher::md5Hash(fileN);
+               if ( QFile::exists(fileN) && Hasher::md5Hash(fileN) == hash) {
                        if (docDownloader.isTransfering(name)) { //we are 
downlaoding this document, just wait for it
                                return;
                        }
@@ -234,9 +245,18 @@
                        downloadableDoc->load(name, docId.toInt());
                        emit exhibitStartEvent(docId.toInt() , to_id.toInt());
                } else {
+                       if ( QFile::exists(fileN) ) { //it means that the hash 
is wrong
+                               QtLockedFile * file = new QtLockedFile(fileN);
+                               if (! file->isLocked()) {
+                                       QFile::remove(fileN);
+                               } else {
+                                       qDebug() << "file is locked!";
+                               }
+                               delete file;
+                       }
                        //disable(true); //nedovolime sosat vice dokumentu naraz
                        emit downloadStartEvent(docId.toInt());
-                       docDownloader.getDocument(to_id, docId, name);
+                       docDownloader.getDocument(to_id, docId, name, hash);
                }
        }
 }
@@ -248,9 +268,9 @@
        connect((XMLDocumentParser *)parser, SIGNAL(setStartAt(QString &, 
qint64)), this, SLOT(setStartAt(QString&, qint64)));
        connect((XMLDocumentParser *)parser, SIGNAL(setAutoStart(QString &, 
bool)), this, SLOT(setAutoStart(QString&, bool)));
        connect((XMLDocumentParser *)parser, SIGNAL(noneDocument(QString &)), 
this, SLOT (closeDocument(QString & )));
-       connect((XMLDocumentParser *)parser, SIGNAL(newPDFDocument(QString &, 
QString &, QString&)), this, SLOT(newPDFDocument(QString &, QString &, 
QString&)));
-       connect((XMLDocumentParser *)parser, SIGNAL(newPDFPresentation(QString 
&, QString &, QString&)), this, SLOT(newPDFPresentation(QString &, QString &, 
QString&)));
-       connect((XMLDocumentParser *)parser, SIGNAL(newVideoDocument(QString &, 
QString &, QString&)), this, SLOT(newVideoDocument(QString &, QString &, 
QString&)));
+       connect((XMLDocumentParser *)parser, SIGNAL(newPDFDocument(QString &, 
QString &, QString&, QString &)), this, SLOT(newPDFDocument(QString &, QString 
&, QString&, QString &)));
+       connect((XMLDocumentParser *)parser, SIGNAL(newPDFPresentation(QString 
&, QString &, QString&, QString &)), this, SLOT(newPDFPresentation(QString &, 
QString &, QString&, QString &)));
+       connect((XMLDocumentParser *)parser, SIGNAL(newVideoDocument(QString &, 
QString &, QString&, QString &)), this, SLOT(newVideoDocument(QString &, 
QString &, QString&, QString &)));
 
        connect((XMLDocumentParser *)parser, SIGNAL(newStaticText(QString&, 
QString&, QString&, int, QString&, QString &)),
                this, SLOT(newStaticText(QString&, QString&, QString&, int, 
QString&, QString &)));
@@ -320,10 +340,11 @@
        QCoreApplication::postEvent(Statistics::getInstance(), e);
 }
 
-void DocumentMaintainer::downloadCompleteEventHandler(QString & toId, QString 
& docId, QString & documentName) {
+void DocumentMaintainer::downloadCompleteEventHandler(QString & toId, QString 
& docId, QString & documentName, QString & hash) {
        StatisticEvent * e = new 
StatisticEvent((QEvent::Type)AppConfig::getInstance()->getStatisticEventType());
        Q_UNUSED(toId);
        Q_UNUSED(documentName);
+       Q_UNUSED(hash);
 
        e->setSubType(ElvysNs::downloadFinishedEvent);
        e->setDocId(docId.toInt());

Modified: trunk/client/elvys-client/src/documentmaintainer.h
===================================================================
--- trunk/client/elvys-client/src/documentmaintainer.h  2010-02-27 15:34:39 UTC 
(rev 1922)
+++ trunk/client/elvys-client/src/documentmaintainer.h  2010-02-27 19:00:44 UTC 
(rev 1923)
@@ -5,9 +5,11 @@
 #include <QRect>
 #include <QMap>
 #include <QWidget>
+#include <QtLockedFile>
 #include "statisticevent.h"
 #include "http.h"
 #include "abstractmaintainer.h"
+#include "hasher.h"
 
 
  class DocumentMaintainer : public AbstractMaintainer {
@@ -28,14 +30,14 @@
                void setAutoStart(QString & toId, bool autoStart);
                void setStartAt(QString & toId, qint64 startAt);
                void setPeriod(QString & toId, int period);
-               void newPDFDocument(QString &, QString &, QString & );
-               void newPDFPresentation(QString & to_id, QString & docId, 
QString & name);
-               void newVideoDocument(QString &, QString &, QString & );
-               void newDownloadableDocument(QString &, QString &, QString &);
+               void newPDFDocument(QString &, QString &, QString &, QString & 
hash );
+               void newPDFPresentation(QString & to_id, QString & docId, 
QString & name, QString & hash);
+               void newVideoDocument(QString &, QString &, QString &, QString 
& );
+               void newDownloadableDocument(QString &, QString &, QString &, 
QString & hash);
                void newStaticText(QString &, QString&, QString&, int, 
QString&, QString & );
                void newDynamicText(QString &, QString&, QString&, int, 
QString&, QString &, QString & );
                void downloadStartEventHandler(int docId);
-               void downloadCompleteEventHandler(QString & toId, QString & 
docId, QString & documentName);
+               void downloadCompleteEventHandler(QString & toId, QString & 
docId, QString & documentName, QString & hash);
                void exhibitCompleteEventHandler(int documentId, int 
layoutPosition);
 
        private slots:
@@ -49,7 +51,7 @@
                QStringList currentlyDownloading();
 
        private:
-               template <class T> void newDownloadableDocument(QString &, 
QString &, QString &);
+               template <class T> void newDownloadableDocument(QString &, 
QString &, QString &, QString & hash);
                void disconnectSignals();
                void connectSignals();
 

Modified: trunk/client/elvys-client/src/filecachemaintainer.cpp
===================================================================
--- trunk/client/elvys-client/src/filecachemaintainer.cpp       2010-02-27 
15:34:39 UTC (rev 1922)
+++ trunk/client/elvys-client/src/filecachemaintainer.cpp       2010-02-27 
19:00:44 UTC (rev 1923)
@@ -12,7 +12,8 @@
 
        connect(parser, SIGNAL(newFile(QString & , QString &, qint64 , QString 
&)), this, SLOT(downloadFile(QString&, QString &, qint64, QString&)));
 
-       connect(&docDownloader, SIGNAL(gotDocument(QString &, QString &, 
QString &)), this, SLOT(downloadCompleteEventHandler(QString &, QString &, 
QString &)));
+       connect(&docDownloader, SIGNAL(gotDocument(QString &, QString &, 
QString &, QString &)), this, SLOT(downloadCompleteEventHandler(QString &, 
QString &, QString &, QString &)));
+       connect(&docDownloader, SIGNAL(docDownloadFailed(QString &, QString &, 
QString &, QString &)), this, SLOT(downloadFailed(QString &, QString &, QString 
&, QString &)));
        connect(this, SIGNAL(downloadStartEvent(int)), this, 
SLOT(downloadStartEventHandler(int)));
 
        connect(parser, SIGNAL(readFailed()), this, SLOT(deleteTempFile()));
@@ -58,18 +59,32 @@
 }
 
 void FileCacheMaintainer::downloadFile(QString & fileName, QString & docId, 
qint64 size, QString & md5sum) {
-       Q_UNUSED(size);
-       Q_UNUSED(md5sum);
+       Q_UNUSED(size); 
        QString toId = QString::number(-1);
 
+
        int documentId = docId.toInt();
 
-       if ( QFile::exists(_dataDir + fileName) || 
docDownloader.isTransfering(fileName)) {
+       if  (docDownloader.isTransfering(fileName)) {
                return;
        }
 
+       if (QFile::exists(_dataDir + fileName) && Hasher::md5Hash(_dataDir + 
fileName) != md5sum) {
+               QtLockedFile * file = new QtLockedFile(fileName);
+               if (! file->isLocked()) {
+                       QFile::remove(_dataDir + fileName);
+               } else {
+                       qDebug() << "file is locked!";
+               }
+               delete file;
+       }
+
+       if ( QFile::exists(_dataDir + fileName)) { //now we now that md5sum is 
OK
+               return;
+       }
+
        emit downloadStartEvent(documentId);
-       docDownloader.getDocument(toId, docId, fileName);
+       docDownloader.getDocument(toId, docId, fileName, md5sum);
 }
 
 void FileCacheMaintainer::downloadStartEventHandler(int docId) {
@@ -81,10 +96,24 @@
        QCoreApplication::postEvent(Statistics::getInstance(), e);
 }
 
-void FileCacheMaintainer::downloadCompleteEventHandler(QString & toId, QString 
& docId, QString & documentName) {
+void FileCacheMaintainer::downloadFailed(QString & toId, QString & docId, 
QString & documentName, QString & md5sum) {
+       StatisticEvent * e = new 
StatisticEvent((QEvent::Type)AppConfig::getInstance()->getStatisticEventType());
       
+       Q_UNUSED(toId);
+       Q_UNUSED(documentName);
+       Q_UNUSED(md5sum);
+
+       e->setSubType(ElvysNs::downloadFinishedEvent);
+       e->setDocId(docId.toInt());
+
+       QCoreApplication::postEvent(Statistics::getInstance(), e);
+}
+
+
+void FileCacheMaintainer::downloadCompleteEventHandler(QString & toId, QString 
& docId, QString & documentName, QString & md5sum) {
        StatisticEvent * e = new 
StatisticEvent((QEvent::Type)AppConfig::getInstance()->getStatisticEventType());
        Q_UNUSED(toId);
        Q_UNUSED(documentName);
+       Q_UNUSED(md5sum);
 
        e->setSubType(ElvysNs::downloadFinishedEvent);
        e->setDocId(docId.toInt());

Modified: trunk/client/elvys-client/src/filecachemaintainer.h
===================================================================
--- trunk/client/elvys-client/src/filecachemaintainer.h 2010-02-27 15:34:39 UTC 
(rev 1922)
+++ trunk/client/elvys-client/src/filecachemaintainer.h 2010-02-27 19:00:44 UTC 
(rev 1923)
@@ -2,11 +2,12 @@
 #define FILECACHEMAINTAINER_H
 
 #include <QCoreApplication>
-
+#include <QtLockedFile>
 #include "abstractmaintainer.h"
 #include "xmlfilecacheparser.h"
 #include "statisticevent.h"
 #include "statistics.h"
+#include "hasher.h"
 
 class FileCacheMaintainer : public AbstractMaintainer {
        Q_OBJECT
@@ -25,8 +26,9 @@
 
 private slots:
        void downloadFile(QString & fileName, QString & docId, qint64 size, 
QString & md5sum);
+       void downloadFailed(QString & toId, QString & docId, QString &name, 
QString & md5sum);
        void downloadStartEventHandler(int docId);
-       void downloadCompleteEventHandler(QString & toId, QString & docId, 
QString & documentName);
+       void downloadCompleteEventHandler(QString & toId, QString & docId, 
QString & documentName, QString & md5sum);
 
 private:
        Http docDownloader;

Added: trunk/client/elvys-client/src/hasher.cpp
===================================================================
--- trunk/client/elvys-client/src/hasher.cpp                            (rev 0)
+++ trunk/client/elvys-client/src/hasher.cpp    2010-02-27 19:00:44 UTC (rev 
1923)
@@ -0,0 +1,42 @@
+#include "hasher.h"
+
+Hasher::Hasher() {
+}
+
+
+/** Computes md5 hash of the file @fileName
+  @arg fileName name of file from which to compute md5 hash
+  @return md5 hash of the file or empty string in case of error
+  */
+
+QString Hasher::md5Hash(QString fileName) {
+       if (! QFile::exists(fileName)) {
+               return "";
+       }
+
+       QCryptographicHash * hash = new 
QCryptographicHash(QCryptographicHash::Md5);
+       QFile * file = new QFile(fileName);
+
+       if(!file->open(QIODevice::ReadOnly | QIODevice::Unbuffered)) {
+               qWarning() << Q_FUNC_INFO << "Cannot open file" << fileName;
+               delete file;
+               delete hash;
+               return "";
+       }
+
+       QByteArray buffer;
+       qint64 bufSize = Q_INT64_C(256*1024);
+
+       while(!(buffer = file->read(bufSize)).isEmpty())        {
+               hash->addData(buffer);  
+       }
+
+       QByteArray result = hash->result().toHex();
+       qDebug() << "hash je " << fileName << result.data();
+       delete hash;
+       file->close();
+       delete file;
+
+       return QString(result);
+}
+

Added: trunk/client/elvys-client/src/hasher.h
===================================================================
--- trunk/client/elvys-client/src/hasher.h                              (rev 0)
+++ trunk/client/elvys-client/src/hasher.h      2010-02-27 19:00:44 UTC (rev 
1923)
@@ -0,0 +1,20 @@
+#ifndef HASHER_H
+#define HASHER_H
+
+#include <QCryptographicHash>
+#include <QString>
+#include <QFile>
+#include <QDebug>
+#include <QObject>
+
+class Hasher : public QObject {
+
+       public:
+       Hasher();
+       static QString md5Hash(QString fileName);
+
+       private:
+
+};
+
+#endif // HASHER_H

Modified: trunk/client/elvys-client/src/http.cpp
===================================================================
--- trunk/client/elvys-client/src/http.cpp      2010-02-27 15:34:39 UTC (rev 
1922)
+++ trunk/client/elvys-client/src/http.cpp      2010-02-27 19:00:44 UTC (rev 
1923)
@@ -49,7 +49,7 @@
 void Http::downloadPOSTreal(const QString & id, const HttpAddress & address, 
QString & fileName, QString & userAgent) {
        int reqId;
        QString realFileName = fileName + fileSuffix;
-       QFile * tmpFile;        
+       QtLockedFile * tmpFile;
        QHttp * http = NULL;
 
        mtx.lock();
@@ -76,7 +76,7 @@
        http->setHost(address.host, address.port);
        //qDebug() << "downloading document " <<  id;
 
-       tmpFile = new QFile(realFileName);
+       tmpFile = new QtLockedFile(realFileName);
 
        QHttpRequestHeader header("POST", address.path);
 
@@ -249,7 +249,7 @@
        QString filename = docIdent.name;
        int reqId;
        HttpAddress address = AppConfig::getInstance()->getDataAddress();
-       QFile * file = new 
QFile(QString(AppConfig::getInstance()->getLocalDataDir()) + filename);
+       QtLockedFile * file = new 
QtLockedFile(QString(AppConfig::getInstance()->getLocalDataDir()) + filename);
        QHttp * http = NULL;
 
        docIdent.file = file;
@@ -278,7 +278,8 @@
        http->setHost(address.host, address.port);
        //qDebug()<< Q_FUNC_INFO << "Host:" << address.host;
        //qDebug() << Q_FUNC_INFO << "path: " << address.path;
-
+       file->open(QtLockedFile::WriteOnly);
+       file->lock(QtLockedFile::WriteLock);
        reqId = http->get(QString(address.path) + "/" + filename, file);
 
        mtx.lock();
@@ -289,7 +290,7 @@
        //QTimer::singleShot(AppConfig::getInstance()->getHTTPTimeout(), this, 
SLOT(reqTimeout()));
 }
 
-void Http::getDocument(QString & toId, QString & docId, QString & filename) {  
                
+void Http::getDocument(QString & toId, QString & docId, QString & filename, 
QString & hash) {
        docIdentifier docIdent; 
 
        mtx.lock();
@@ -303,6 +304,7 @@
        docIdent.name = filename;
        docIdent.toId = toId;
        docIdent.docId = docId; 
+       docIdent.hash = hash;
 
        if (numDownloads() > MAX_DOWNLOADS) {
                //qDebug() << Q_FUNC_INFO << "There are too many transfers at 
the moment (" << numDownloads() << "), queueing.";
@@ -353,7 +355,8 @@
        QString name;
        QString toId;
        QString docId;  
-       QFile * file;
+       QString hash;
+       QtLockedFile * file;
        if (http == NULL) {
                qWarning() << Q_FUNC_INFO << "sender cast to QObject failed!!!";
                return;
@@ -370,24 +373,32 @@
                if (error || (responseHeader.statusCode() != 200)) { //error
                        file = docDownloads[id].file;
                        //qDebug() << Q_FUNC_INFO << "Error downloading 
document filename:" << file->fileName() << "." << http->errorString();
-                       //qDebug() << Q_FUNC_INFO << "http status code:" << 
responseHeader.statusCode();
+                       //qDebug() << Q_FUNC_INFO << "http status code:" << 
responseHeader.statusCode();                        
                        file->remove();
                        file->close();
                        delete file;
+                       emit docDownloadFailed(toId, docId, name, hash);
                        transfers.remove(docDownloads[id].name);
                        docDownloads.remove(id);
                        mtx.unlock();                   
                } else {
                        name = docDownloads[id].name;
+                       hash = docDownloads[id].hash;
                        docId = docDownloads[id].docId;
                        toId = docDownloads[id].toId;
-                       file = docDownloads[id].file;
+                       file = docDownloads[id].file;                           
                
+                       docDownloads.remove(id);
+                       transfers.remove(name);                 
                        file->close();
+                       if ( Hasher::md5Hash(name) == hash ) {
+                               emit gotDocument(toId, docId, name, hash);
+                       } else {
+                               emit docDownloadFailed(toId, docId, name, hash);
+                               file->remove();
+                       }
+
                        delete file;
-                       docDownloads.remove(id);
-                       transfers.remove(name);
                        mtx.unlock();
-                       emit gotDocument(toId, docId, name);
                }
                downloadsCount--;
                downHttps[http] = false;

Modified: trunk/client/elvys-client/src/http.h
===================================================================
--- trunk/client/elvys-client/src/http.h        2010-02-27 15:34:39 UTC (rev 
1922)
+++ trunk/client/elvys-client/src/http.h        2010-02-27 19:00:44 UTC (rev 
1923)
@@ -4,9 +4,10 @@
 #include <QHttp>
 #include <QUrl>
 #include <QMutex>
-#include <QFile>
+#include <QtLockedFile>
 #include <QList>
 #include "appconfig.h"
+#include "hasher.h"
 
 #define MAX_DOWNLOADS 2
 #define MAX_UPLOADS 2
@@ -19,7 +20,8 @@
        QString name;
        QString toId;
        QString docId;
-       QFile * file;
+       QString hash;
+       QtLockedFile * file;
 };
 
 struct HttpReq {
@@ -36,7 +38,8 @@
        Q_OBJECT
 
        signals:
-               void gotDocument(QString & toId, QString & docId, QString & 
name);
+               void gotDocument(QString & toId, QString & docId, QString & 
name, QString & hash);
+               void docDownloadFailed(QString & toId, QString & docId, QString 
&name, QString & hash);
                void uploadComplete(QString &id);
                void uploadFailed(const QString &id);
                void downloadComplete(QString &id);
@@ -56,7 +59,7 @@
        public:
                Http();
                ~Http();
-               void getDocument(QString & toId, QString & docId, QString & 
name);
+               void getDocument(QString & toId, QString & docId, QString & 
name, QString & hash);
                bool isTransfering(QString identifier);
                QStringList currentlyDownloading();
                void setDefaultUserAgent(const QString & agent);
@@ -75,7 +78,7 @@
                QMap<int, docIdentifier> docDownloads; /// for tracking 
documentDownload RequestsID
                QMap<int, QString> downloads; /// for tracking download 
RequestsID
                QMap<int, QString> uploads; /// for tracking upload RequestsID
-               QMap<QString, QFile *> transfers; /// for determining if same 
file is not being uploaded / downloaded.
+               QMap<QString, QtLockedFile *> transfers; /// for determining if 
same file is not being uploaded / downloaded.
                QList<HttpReq> reqQueue; /// request queue
 
                QMap<QHttp *, bool> downHttps; ///< list of objects for 
downloading, bool indicates if given http is beinig used or not

Modified: trunk/client/elvys-client/src/src.pro
===================================================================
--- trunk/client/elvys-client/src/src.pro       2010-02-27 15:34:39 UTC (rev 
1922)
+++ trunk/client/elvys-client/src/src.pro       2010-02-27 19:00:44 UTC (rev 
1923)
@@ -1,4 +1,5 @@
-INCLUDEPATH += serial
+INCLUDEPATH += serial \
+   qtlockedfile
 DEPENDPATH += serial
 SOURCES += main.cpp \
     pdfdocument.cpp \
@@ -50,7 +51,8 @@
     pdfpresentationdocument.cpp \
     pdfpresentationviewer.cpp \
     pdfcommonviewer.cpp \
-    timestamper.cpp
+    timestamper.cpp \
+    hasher.cpp
 HEADERS += elvys.h \
     pdfdocument.h \
     pdffiller.h \
@@ -103,7 +105,8 @@
     pdfpresentationdocument.h \
     pdfpresentationviewer.h \
     pdfcommonviewer.h \
-    timestamper.h
+    timestamper.h \
+    hasher.h
 TEMPLATE = app
 CONFIG += warn_on \
     thread \
@@ -121,7 +124,8 @@
     -L/usr/lib \
     -lsqlite \
     -lphonon \
-    -lXpdfRasterizer
+       -lXpdfRasterizer \
+       -lQtSolutions_LockedFile-2.4
 INCLUDEPATH += /usr/include/XpdfRasterizer/
 INCLUDEPATH += /usr/include/KDE
 CONFIG -= release

Modified: trunk/client/elvys-client/src/statisticsdata.cpp
===================================================================
--- trunk/client/elvys-client/src/statisticsdata.cpp    2010-02-27 15:34:39 UTC 
(rev 1922)
+++ trunk/client/elvys-client/src/statisticsdata.cpp    2010-02-27 19:00:44 UTC 
(rev 1923)
@@ -459,7 +459,7 @@
 
 }
 
-/** Deletes events in database, which were uploadded in uploaded with id @a id.
+/** Deletes events in database, which were uploaded with id @a id.
   *@param id id of completed upload
   */
 

Modified: trunk/client/elvys-client/src/videodocument.cpp
===================================================================
--- trunk/client/elvys-client/src/videodocument.cpp     2010-02-27 15:34:39 UTC 
(rev 1922)
+++ trunk/client/elvys-client/src/videodocument.cpp     2010-02-27 19:00:44 UTC 
(rev 1923)
@@ -44,8 +44,13 @@
 
 
 
-void VideoDocument::managePlayerState() {
-
+void VideoDocument::managePlayerState(Phonon::State prevState, Phonon::State 
newState) {
+       if (newState == Phonon::ErrorState) {
+               if ( player->mediaObject()->errorType() == Phonon::FatalError ) 
{
+                       qWarning() << "error occured playing video"  << _name 
<< ":" << player->mediaObject()->errorString();                   
+                       close();
+               }
+       }
 }
 
 

Modified: trunk/client/elvys-client/src/videodocument.h
===================================================================
--- trunk/client/elvys-client/src/videodocument.h       2010-02-27 15:34:39 UTC 
(rev 1922)
+++ trunk/client/elvys-client/src/videodocument.h       2010-02-27 19:00:44 UTC 
(rev 1923)
@@ -3,6 +3,7 @@
 
 #include <QKeyEvent>
 #include <QVBoxLayout>
+#include <QDebug>
 #include <Phonon/VideoWidget>
 #include <Phonon/VideoPlayer>
 #include <Phonon/MediaObject>
@@ -54,7 +55,7 @@
                virtual void resizeEvent(QResizeEvent * event);
 
        private slots:
-               void managePlayerState();
+               void managePlayerState(Phonon::State prevState, Phonon::State 
newState);
                void replay();
                void play();
                void completelyUnZoom();

Modified: trunk/client/elvys-client/src/xmldocumentparser.cpp
===================================================================
--- trunk/client/elvys-client/src/xmldocumentparser.cpp 2010-02-27 15:34:39 UTC 
(rev 1922)
+++ trunk/client/elvys-client/src/xmldocumentparser.cpp 2010-02-27 19:00:44 UTC 
(rev 1923)
@@ -95,6 +95,7 @@
 bool XMLDocumentParser::readVideo() {
        QString filename;
        QString docId;
+       QString hash;
        Q_ASSERT(isStartElement() && name() == "video");
        int startAt = -1;
        bool autoStart = false;
@@ -109,23 +110,15 @@
                        break;
                }
 
-               if (isStartElement()) {
-                       if (name() == "id") {
-                               docId = readElementText();
+               if (isStartElement()) {                 
+                       if (name() == "file") {
+                               filename = 
attributes().value("name").toString();
+                               docId = attributes().value("id").toString();
+                               hash = attributes().value("hash").toString();
                                if ( docId != "" && filename != "") {
-                                       emit newVideoDocument(toId, docId, 
filename);
+                                       emit newVideoDocument(toId, docId, 
filename, hash);
                                }
-                               readNext();
-                       } else if (name() == "name") {
-                               filename = readElementText();
-                               if ( docId != "" && filename != "") {
-                                       emit newVideoDocument(toId, docId, 
filename);
-                               }
-                               readNext(); //end element                       
-                       } else if (name() == "orig-name") {
-                         //ignore it now
-                               readElementText();
-                               readNext(); // end element
+                               readNext(); //end element                       
                        
                        } else if (name() == "autostart") {
                                if (readElementText() == "true" ) {
                                        autoStart = true;
@@ -150,6 +143,7 @@
 bool XMLDocumentParser::readPDFDocument() {
        QString filename;
        QString docId;
+       QString hash;
        Q_ASSERT(isStartElement() && name() == "pdf_doc");
 
        toId = attributes().value("to_id").toString();
@@ -163,24 +157,16 @@
                }
 
                if (isStartElement()) {
-                       if (name() == "id") {
-                               docId = readElementText();
+                       if (name() == "file") {
+                               filename = 
attributes().value("name").toString();
+                               docId = attributes().value("id").toString();
+                               hash = attributes().value("hash").toString();
                                if ( docId != "" && filename != "") {
-                                       emit newPDFDocument(toId, docId, 
filename);
+                                       emit newPDFDocument(toId, docId, 
filename, hash);
                                }
-                               readNext();
-                       } else if (name() == "name") {
-                               filename = readElementText();
-                               if ( docId != "" && filename != "") {
-                                       emit newPDFDocument(toId, docId, 
filename);
-                               }
                                readNext(); //end element
                        } else if (name() == "pages") {
-                               readPages();
-                       } else if (name() == "orig-name") {
-                         //ignore it now
-                               readElementText();
-                               readNext(); // end element
+                               readPages();                    
                        } else {
                                //qDebug() << Q_FUNC_INFO << "NOT 
IMPLEMENTED???" << name().toString();
                                return false;
@@ -194,6 +180,7 @@
 bool XMLDocumentParser::readPDFPresentation() {
        QString filename;
        QString docId;
+       QString hash;
        int period = 0;
        Q_ASSERT(isStartElement() && name() == "pdf_presentation");
 
@@ -208,30 +195,19 @@
                }
 
                if (isStartElement()) {
-                       if (name() == "id") {
-                               docId = readElementText();
+                       if (name() == "file") {
+                               filename = 
attributes().value("name").toString();
+                               docId = attributes().value("id").toString();
+                               hash = attributes().value("hash").toString();
                                if ( docId != "" && filename != "") {
-                                       emit newPDFPresentation(toId, docId, 
filename);
+                                       emit newPDFPresentation(toId, docId, 
filename, hash);
                                }
-                               readNext();
-                       } else if (name() == "name") {
-                               filename = readElementText();
-                               if ( docId != "" && filename != "") {
-                                       emit newPDFPresentation(toId, docId, 
filename);
-                               }
                                readNext(); //end element
                        } else if (name() == "pages") {
                                readPages();
                        } else if (name() == "period") {
-                               period = readPeriod();
-                               if ( docId != "" && filename != "") {
-                                       emit newPDFPresentation(toId, docId, 
filename);
-                               }
-                               emit setPeriod(toId, period);
-                       } else if (name() == "orig-name") {
-                         //ignore it now
-                               readElementText();
-                               readNext(); // end element
+                               period = readPeriod();                          
+                               emit setPeriod(toId, period);                   
                        } else {
                                //qDebug() << Q_FUNC_INFO << "NOT 
IMPLEMENTED???" << name().toString();
                                return false;

Modified: trunk/client/elvys-client/src/xmldocumentparser.h
===================================================================
--- trunk/client/elvys-client/src/xmldocumentparser.h   2010-02-27 15:34:39 UTC 
(rev 1922)
+++ trunk/client/elvys-client/src/xmldocumentparser.h   2010-02-27 19:00:44 UTC 
(rev 1923)
@@ -14,12 +14,12 @@
 
        signals:
                void setPages(QString & toId, QList<int> & _pages, int 
mainPage);
-               void newPDFDocument(QString & toId, QString & docId, QString & 
_name);
-               void newPDFPresentation(QString & toId, QString & docId, 
QString & _name);
+               void newPDFDocument(QString & toId, QString & docId, QString & 
_name, QString & hash);
+               void newPDFPresentation(QString & toId, QString & docId, 
QString & _name, QString & hash);
                void setPeriod(QString & toId, int period);
                void setAutoStart(QString & toId, bool autoStart);
                void setStartAt(QString & toId, qint64 startAt);
-               void newVideoDocument(QString & toId, QString & docId, QString 
& _name);
+               void newVideoDocument(QString & toId, QString & docId, QString 
& _name, QString & hash);
                void newStaticText(QString & toId, QString & text, QString & 
fontName, int size, QString & colorName, QString & colorNameBg);
                void newDynamicText(QString & toId, QString & text, QString & 
fontName, int size, QString & colorName, QString & colorNameBg, QString & 
order);
                void haveLayoutId(int _layoutId);
@@ -34,6 +34,7 @@
        private:
                bool readDocument();
                QString readName();
+               bool readFile();
                bool readPDFDocument();
                bool readPDFPresentation();
                bool readHTMLDocument();


Other related posts:

  • » [elvystrac] r1923 - make sures that downloaded files are OK via md5 checksum - elvys