|
楼主 |
发表于 2009-12-21 18:56:32
|
显示全部楼层
Index: core/document.cpp
===================================================================
--- core/document.cpp (Revision 85947
+++ core/document.cpp (Arbeitskopie)
@@ -16,6 +16,8 @@
#include <windows.h>
#endif
+#include <mhash.h>
+
// qt/kde/system includes
#include <QtCore/QtAlgorithms>
#include <QtCore/QDir>
@@ -1367,12 +1369,21 @@
// determine the related "xml document-info" filename
d->m_url = url;
d->m_docFileName = docFile;
- if ( url.isLocalFile() )
- {
- QString fn = url.fileName();
- document_size = fileReadTest.size();
- fn = QString::number( document_size ) + '.' + fn + ".xml";
+ MHASH t = mhash_init(MHASH_MD5);
+
+ if(t == MHASH_FAILED)
+ return false;
+
+ mhash(t, fileReadTest.readAll().data(), fileReadTest.size());
+ unsigned char hash_bin[16];
+ char hash_asc[33];
+ mhash_deinit(t, hash_bin);
fileReadTest.close();
+
+ for(int i = 0; i < 16; ++i)
+ sprintf(hash_asc + 2 * i, "%02x", (int)hash_bin);
+
+ QString fn = QString(hash_asc) + ".xml";
QString newokular = "okular/docdata/" + fn;
QString newokularfile = KStandardDirs::locateLocal( "data", newokular );
if ( !QFile::exists( newokularfile ) )
@@ -1387,7 +1398,6 @@
}
}
d->m_xmlFileName = newokularfile;
- }
}
else
{
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (Revision 85947
+++ CMakeLists.txt (Arbeitskopie)
@@ -100,7 +100,7 @@
SET(OKULAR_IOKIT "-framework IOKit" CACHE STRING "Apple IOKit framework")
ENDIF(APPLE)
-target_link_libraries(okularcore ${OKULAR_IOKIT} ${KDE4_KIO_LIBS} ${KDE4_PHONON_LIBRARY} ${KDE4_KJSAPI_LIBRARY} ${MATH_LIB} ${KDE4_THREADWEAVER_LIBRARY} )
+target_link_libraries(okularcore ${OKULAR_IOKIT} ${KDE4_KIO_LIBS} ${KDE4_PHONON_LIBRARY} ${KDE4_KJSAPI_LIBRARY} ${MATH_LIB} ${KDE4_THREADWEAVER_LIBRARY} mhash )
set_target_properties(okularcore PROPERTIES VERSION 1.1.0 SOVERSION 1 ) |
|