Index: strigi/ConfigureChecks.cmake
===================================================================
--- strigi/ConfigureChecks.cmake	(revision 768525)
+++ strigi/ConfigureChecks.cmake	(working copy)
@@ -10,10 +10,20 @@
 CHECK_INCLUDE_FILE_CXX(windows.h HAVE_WINDOWS_H)        # src/streamindexer/filelister.cpp
 
 # files that may define the u?int{8,16,32,54}_t types
-CHECK_INCLUDE_FILE_CXX(socket.h HAVE_SOCKET_H)
-CHECK_INCLUDE_FILE_CXX(sys/socket.h HAVE_SYS_SOCKET_H)
+if(MSVC)
+  ADD_DEFINITIONS(-DHAVE_SOCKET_H=1 -DHAVE_SYS_SOCKET_H=1 -DHAVE_UNISTD_H=1 -DHAVE_SYS_STAT_H=1 
+    -DHAVE_NANOSLEEP=1 -DHAVE_SLEEP=1)
+else(MSVC)
+  CHECK_INCLUDE_FILE_CXX(socket.h HAVE_SOCKET_H)
+  CHECK_INCLUDE_FILE_CXX(sys/socket.h HAVE_SYS_SOCKET_H)
+  CHECK_INCLUDE_FILE_CXX(unistd.h HAVE_UNISTD_H)          # src/streamindexer/pluginendanalyzer.cpp
+  CHECK_INCLUDE_FILE_CXX(sys/stat.h HAVE_SYS_STAT_H)      # S_ISDIR...
+  CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)         # src/storage/sqlitestorage.cpp, src/daemon/indexscheduler.cpp, src/searchclient/cmdlinestrigi.cpp
+  CHECK_FUNCTION_EXISTS(sleep HAVE_SLEEP)                 # src/storage/sqlitestorage.cpp, src/daemon/indexscheduler.cpp, src/searchclient/cmdlinestrigi.cpp
+  CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP)             # src/streamanalyzer/helperendanalyzer.cpp
+endif(MSVC)
+
 CHECK_INCLUDE_FILE_CXX(sys/types.h HAVE_SYS_TYPES_H)
-CHECK_INCLUDE_FILE_CXX(unistd.h HAVE_UNISTD_H)          # src/streamindexer/pluginendanalyzer.cpp
 CHECK_INCLUDE_FILE_CXX(stdint.h HAVE_STDINT_H)          # config.h, strigiconfig.h
 CHECK_INCLUDE_FILE_CXX(regex.h HAVE_REGEX_H)            # src/dummyindexer/*
 
@@ -22,8 +32,6 @@
 CHECK_FUNCTION_EXISTS(fchdir HAVE_FCHDIR)               # unused !
 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)   # src/luceneindexer/cluceneindexmanager.cpp, src/luceneindexer/cluceneindexreader.cpp, src/streams/strigi/timeofday.h
 CHECK_FUNCTION_EXISTS(isblank HAVE_ISBLANK)             # src/streams/mailinputstream.cpp, src/streams/strigi/compat.cpp
-CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP)             # src/streamanalyzer/helperendanalyzer.cpp
-CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)         # src/storage/sqlitestorage.cpp, src/daemon/indexscheduler.cpp, src/searchclient/cmdlinestrigi.cpp
 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)       # src/streamindexer/expatsaxendanalyzer.cpp, src/streamindexer/saxendanalyzer.cpp
 CHECK_FUNCTION_EXISTS(strcasestr HAVE_STRCASESTR)       # src/streams/mailinputstream.cpp
 CHECK_FUNCTION_EXISTS(strlwr HAVE_STRLWR)               # src/streamindexer/ifilterendanalyzer.cpp
Index: strigi/src/luceneindexer/jsgzipcompressstream.cpp
===================================================================
--- strigi/src/luceneindexer/jsgzipcompressstream.cpp	(revision 768525)
+++ strigi/src/luceneindexer/jsgzipcompressstream.cpp	(working copy)
@@ -17,6 +17,14 @@
  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301, USA.
  */
+
+#ifdef _MSC_VER
+# define __int32_t_defined
+# define __uint32_t_defined
+# include <winsock2.h>
+#endif
+#include <CLucene.h>
+
 #include "jsgzipcompressstream.h"
 #include <CLucene/util/jstreamsconfig.h>
 #include <zlib.h>
Index: strigi/src/luceneindexer/cluceneindexmanager.cpp
===================================================================
--- strigi/src/luceneindexer/cluceneindexmanager.cpp	(revision 768525)
+++ strigi/src/luceneindexer/cluceneindexmanager.cpp	(working copy)
@@ -18,13 +18,19 @@
  * Boston, MA 02110-1301, USA.
  */
 
+#ifdef _MSC_VER
+# define __int32_t_defined
+# define __uint32_t_defined
+# include <winsock2.h>
+#endif
+#include <CLucene.h>
+
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
 #include "cluceneindexmanager.h"
 #include <strigi/strigiconfig.h>
-#include <CLucene.h>
 #include "cluceneindexwriter.h"
 #include "cluceneindexreader.h"
 #include "indexplugin.h"
Index: strigi/src/luceneindexer/cluceneindexwriter.cpp
===================================================================
--- strigi/src/luceneindexer/cluceneindexwriter.cpp	(revision 768525)
+++ strigi/src/luceneindexer/cluceneindexwriter.cpp	(working copy)
@@ -18,13 +18,19 @@
  * Boston, MA 02110-1301, USA.
  */
 
+#ifdef _MSC_VER
+# define __int32_t_defined
+# define __uint32_t_defined
+# include <winsock2.h>
+#endif
+#include <CLucene.h>
+
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
 
 #include "cluceneindexwriter.h"
 #include "tcharutils.h"
-#include <CLucene.h>
 #include <CLucene/store/Lock.h>
 #include "cluceneindexreader.h"
 #include "cluceneindexmanager.h"
Index: strigi/src/luceneindexer/indexdump/indexdump.cpp
===================================================================
--- strigi/src/luceneindexer/indexdump/indexdump.cpp	(revision 768525)
+++ strigi/src/luceneindexer/indexdump/indexdump.cpp	(working copy)
@@ -17,6 +17,12 @@
  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  * Boston, MA 02110-1301, USA.
  */
+
+#ifdef _MSC_VER
+# define __int32_t_defined
+# define __uint32_t_defined
+# include <winsock2.h>
+#endif
 #include <CLucene.h>
 #include <CLucene/search/QueryFilter.h>
 #include <sstream>
Index: strigi/src/luceneindexer/cluceneindexreader.cpp
===================================================================
--- strigi/src/luceneindexer/cluceneindexreader.cpp	(revision 768525)
+++ strigi/src/luceneindexer/cluceneindexreader.cpp	(working copy)
@@ -18,6 +18,13 @@
  * Boston, MA 02110-1301, USA.
  */
 
+#ifdef _MSC_VER
+# define __int32_t_defined
+# define __uint32_t_defined
+# include <winsock2.h>
+#endif
+#include <CLucene.h>
+
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #endif
@@ -365,7 +372,11 @@
     if (type == Variant::b_val) {
          v = v.b();
     } else if (type == Variant::i_val) {
+#ifdef _MSC_VER // our int32_t differs from clucene's int32_t
+         v = (long long)atoi(v.s().c_str());
+#else
          v = v.i();
+#endif
     } else if (type == Variant::as_val) {
          v = v.as();
     }
Index: strigi/src/streamanalyzer/variant.h
===================================================================
--- strigi/src/streamanalyzer/variant.h	(revision 768525)
+++ strigi/src/streamanalyzer/variant.h	(working copy)
@@ -50,6 +50,9 @@
     Type type() const;
     const Variant& operator=(bool v);
     const Variant& operator=(int32_t v);
+#ifdef _MSC_VER
+    const Variant& operator=(long long v);
+#endif
     const Variant& operator=(const char* v);
     const Variant& operator=(const std::string& v);
     const Variant& operator=(const std::vector<std::string>& v);
Index: strigi/src/streamanalyzer/endanalyzers/sdfendanalyzer.cpp
===================================================================
--- strigi/src/streamanalyzer/endanalyzers/sdfendanalyzer.cpp	(revision 768525)
+++ strigi/src/streamanalyzer/endanalyzers/sdfendanalyzer.cpp	(working copy)
@@ -59,7 +59,7 @@
 	s = sdf.nextEntry();
     }
     if (moleculeCount)
-	idx.addValue(factory->moleculeCountField, moleculeCount);
+	idx.addValue(factory->moleculeCountField, (int32_t)moleculeCount);
 
     if (sdf.status() == Error) {
         m_error = sdf.error();
Index: strigi/src/streamanalyzer/throughplugins/wavthroughanalyzer.cpp
===================================================================
--- strigi/src/streamanalyzer/throughplugins/wavthroughanalyzer.cpp	(revision 768525)
+++ strigi/src/streamanalyzer/throughplugins/wavthroughanalyzer.cpp	(working copy)
@@ -186,11 +186,11 @@
         return in;
     }
 
-    analysisResult->addValue( factory->sampleSizeField, sample_size );
+    analysisResult->addValue( factory->sampleSizeField, (uint32_t)sample_size );
     analysisResult->addValue( factory->sampleRateField, sample_rate);
-    analysisResult->addValue( factory->channelsField, channel_count);
+    analysisResult->addValue( factory->channelsField, (uint32_t)channel_count);
     unsigned int wav_seconds = data_size / bytes_per_second;
-    analysisResult->addValue( factory->lengthField, wav_seconds);
+    analysisResult->addValue( factory->lengthField, (uint32_t)wav_seconds);
 
     in->reset(0);   // rewind to the start of the stream
     return in;
Index: strigi/src/streamanalyzer/throughplugins/authroughanalyzer.cpp
===================================================================
--- strigi/src/streamanalyzer/throughplugins/authroughanalyzer.cpp	(revision 768525)
+++ strigi/src/streamanalyzer/throughplugins/authroughanalyzer.cpp	(working copy)
@@ -122,7 +122,7 @@
         bytesPerSample = 0;
     }
     if(bytesPerSample) {
-        analysisResult->addValue(factory->sampleBitDepthField, bytesPerSample*8);
+        analysisResult->addValue(factory->sampleBitDepthField, (uint32_t)bytesPerSample*8);
     }
     // work out length from bytespersample + channels + size
     if ((0 < channels) && (0 < dataSize) && (dataSize != 0xFFFFFFFF) && (0 < bytesPerSample) && (0 < sampleRate)) {
Index: strigi/src/streamanalyzer/throughplugins/rgbthroughanalyzer.cpp
===================================================================
--- strigi/src/streamanalyzer/throughplugins/rgbthroughanalyzer.cpp	(revision 768525)
+++ strigi/src/streamanalyzer/throughplugins/rgbthroughanalyzer.cpp	(working copy)
@@ -163,9 +163,9 @@
     // restore file position
     in->reset (pos);
     
-    analysisResult->addValue( factory->widthField, xsize );
-    analysisResult->addValue( factory->heightField, ysize );
-    analysisResult->addValue( factory->bitDepthField, zsize * 8 * bpc );
+    analysisResult->addValue( factory->widthField, (uint32_t)xsize );
+    analysisResult->addValue( factory->heightField, (uint32_t)ysize );
+    analysisResult->addValue( factory->bitDepthField, (uint32_t)zsize * 8 * bpc );
     analysisResult->addValue( factory->imageNameField, imagename);
 
     if (zsize == 1)
Index: strigi/src/streamanalyzer/throughplugins/icothroughanalyzer.cpp
===================================================================
--- strigi/src/streamanalyzer/throughplugins/icothroughanalyzer.cpp	(revision 768525)
+++ strigi/src/streamanalyzer/throughplugins/icothroughanalyzer.cpp	(working copy)
@@ -141,18 +141,18 @@
     uint32_t icoe_imageoffset = readLittleEndianUInt32(c);
 
     // read the data on the 1st icon
-    analysisResult->addValue( factory->numberField, ico_count );
+    analysisResult->addValue( factory->numberField, (uint32_t)ico_count );
 
-    analysisResult->addValue( factory->widthField, icoe_width );
-    analysisResult->addValue( factory->heightField, icoe_height );
+    analysisResult->addValue( factory->widthField, (uint32_t)icoe_width );
+    analysisResult->addValue( factory->heightField, (uint32_t)icoe_height );
 
     if (icoe_bitcount > 0)
-        analysisResult->addValue( factory->bitsPerPixelField, icoe_bitcount );
+        analysisResult->addValue( factory->bitsPerPixelField, (uint32_t)icoe_bitcount );
 
     if (icoe_colorcount > 0)
-        analysisResult->addValue( factory->colorCountField, icoe_colorcount );
+        analysisResult->addValue( factory->colorCountField, (uint32_t)icoe_colorcount );
     else if (icoe_bitcount > 0)
-        analysisResult->addValue( factory->colorCountField, 2 ^ icoe_bitcount );
+        analysisResult->addValue( factory->colorCountField, (uint32_t)2 ^ icoe_bitcount );
     
     in->reset(0);   // rewind to the start of the stream
     return in;
Index: strigi/src/streamanalyzer/throughplugins/ddsthroughanalyzer.cpp
===================================================================
--- strigi/src/streamanalyzer/throughplugins/ddsthroughanalyzer.cpp	(revision 768525)
+++ strigi/src/streamanalyzer/throughplugins/ddsthroughanalyzer.cpp	(working copy)
@@ -347,32 +347,32 @@
     else if( header.pf.flags & DDPF_FOURCC ) {
         switch( header.pf.fourcc ) {
             case FOURCC_DXT1:
-                analysisResult->addValue( factory->bitDepthField, 4);
+                analysisResult->addValue( factory->bitDepthField, (int32_t)4);
                 analysisResult->addValue( factory->compressionField, "DXT1");
                 analysisResult->addValue( factory->colorModeField, "RGB");
                 break;
             case FOURCC_DXT2:
-                analysisResult->addValue( factory->bitDepthField, 16);
+                analysisResult->addValue( factory->bitDepthField, (int32_t)16);
                 analysisResult->addValue( factory->compressionField, "DXT2");
                 analysisResult->addValue( factory->colorModeField, "RGB/Alpha");
                 break;
             case FOURCC_DXT3:
-                analysisResult->addValue( factory->bitDepthField, 16);
+                analysisResult->addValue( factory->bitDepthField, (int32_t)16);
                 analysisResult->addValue( factory->compressionField, "DXT3");
                 analysisResult->addValue( factory->colorModeField, "RGB/Alpha");
                 break;
             case FOURCC_DXT4:
-                analysisResult->addValue( factory->bitDepthField, 16);
+                analysisResult->addValue( factory->bitDepthField, (int32_t)16);
                 analysisResult->addValue( factory->compressionField, "DXT4");
                 analysisResult->addValue( factory->colorModeField, "RGB/Alpha");
                 break;
             case FOURCC_DXT5:
-                analysisResult->addValue( factory->bitDepthField, 16);
+                analysisResult->addValue( factory->bitDepthField, (int32_t)16);
                 analysisResult->addValue( factory->compressionField, "DXT5");
                 analysisResult->addValue( factory->colorModeField, "RGB/Alpha");
                 break;
             case FOURCC_RXGB:
-                analysisResult->addValue( factory->bitDepthField, 16);
+                analysisResult->addValue( factory->bitDepthField, (int32_t)16);
                 analysisResult->addValue( factory->compressionField, "RXGB");
                 analysisResult->addValue( factory->colorModeField, "RGB");
                 break;
Index: strigi/src/streamanalyzer/throughplugins/sidthroughanalyzer.cpp
===================================================================
--- strigi/src/streamanalyzer/throughplugins/sidthroughanalyzer.cpp	(revision 768525)
+++ strigi/src/streamanalyzer/throughplugins/sidthroughanalyzer.cpp	(working copy)
@@ -142,8 +142,8 @@
     analysisResult->addValue( factory->artistField, artist );
     analysisResult->addValue( factory->titleField, title );
     analysisResult->addValue( factory->copyrightField, copyright );
-    analysisResult->addValue( factory->trackNumberField, num_songs );
-    analysisResult->addValue( factory->versionField, version );
+    analysisResult->addValue( factory->trackNumberField, (uint32_t)num_songs );
+    analysisResult->addValue( factory->versionField, (uint32_t)version );
     
     in->reset(0);   // rewind to the start of the stream
     return in;
Index: strigi/src/streamanalyzer/throughplugins/avithroughanalyzer.cpp
===================================================================
--- strigi/src/streamanalyzer/throughplugins/avithroughanalyzer.cpp	(revision 768525)
+++ strigi/src/streamanalyzer/throughplugins/avithroughanalyzer.cpp	(working copy)
@@ -515,14 +515,14 @@
 
         if (0 != avih_microsecperframe)
             analysisResult->addValue( factory->frameRateField,
-                                      int (1000000 / avih_microsecperframe ));
+                                      uint32_t( 1000000 / avih_microsecperframe ));
         
         analysisResult->addValue( factory->resolutionHeightField, avih_width);
         analysisResult->addValue( factory->resolutionHeightField, avih_height);
 
         // work out and add length
         uint64_t mylength = (uint64_t) ((float) avih_totalframes * (float) avih_microsecperframe / 1000000.0);
-        analysisResult->addValue( factory->lengthField, int(mylength));
+        analysisResult->addValue( factory->lengthField, uint32_t(mylength));
 
         if (strlen(handler_vids) > 0)
             analysisResult->addValue( factory->videoCodecField, handler_vids);
Index: strigi/src/streamanalyzer/variant.cpp
===================================================================
--- strigi/src/streamanalyzer/variant.cpp	(revision 768525)
+++ strigi/src/streamanalyzer/variant.cpp	(working copy)
@@ -82,8 +82,15 @@
     p->i_value = v;
     p->vartype = i_val;
     return *this;
-} 
+}
 const Variant&
+Variant::operator=(long long v) {
+    p->valid=true;
+    p->i_value = (int32_t)v;
+    p->vartype = i_val;
+    return *this;
+}
+const Variant&
 Variant::operator=(const char* v) {
     p->valid=true;
     p->s_value.assign(v);
Index: strigi/src/streams/strigi/timeofday.h
===================================================================
--- strigi/src/streams/strigi/timeofday.h	(revision 768525)
+++ strigi/src/streams/strigi/timeofday.h	(working copy)
@@ -19,7 +19,12 @@
 */
 
 #include <errno.h>
+#include <time.h>
 
+#if defined(_MSC_VER)
+#include <sys/time.h>
+#endif
+
 #if defined(_MSC_VER) || defined(__BORLANDC__)
  #define EPOCHFILETIME (116444736000000000i64)
 #else
Index: strigi/src/streams/strigi/compat.h
===================================================================
--- strigi/src/streams/strigi/compat.h	(revision 768525)
+++ strigi/src/streams/strigi/compat.h	(working copy)
@@ -26,6 +26,8 @@
 #endif
 
 #include <strigi/strigiconfig.h>
+#include <string.h>
+#include <unistd.h>
 
 #ifndef HAVE_ISBLANK
 STREAMS_EXPORT int isblank(char c);
Index: strigi/src/streams/strigi/strigiconfig.h.cmake
===================================================================
--- strigi/src/streams/strigi/strigiconfig.h.cmake	(revision 768525)
+++ strigi/src/streams/strigi/strigiconfig.h.cmake	(working copy)
@@ -24,13 +24,17 @@
 
 #define STRIGI_VERSION_STRING "@STRIGI_VERSION@"
 
+#if defined(_WIN32) || defined(_WIN64)
+# include <winsock2.h>
+#endif
+
 /* use the same includes for types finding as in ConfigureChecks.cmake */
+#if @STRIGI_HAVE_SYS_SOCKET_H@
+#  include <sys/socket.h>
+#endif
 #if @STRIGI_HAVE_SOCKET_H@
 #  include <socket.h>
 #endif
-#if @STRIGI_HAVE_SYS_SOCKET_H@
-#  include <sys/socket.h>
-#endif
 #if @STRIGI_HAVE_SYS_TYPES_H@
 #  include <sys/types.h>
 #endif
Index: strigi/src/streams/CMakeLists.txt
===================================================================
--- strigi/src/streams/CMakeLists.txt	(revision 768525)
+++ strigi/src/streams/CMakeLists.txt	(working copy)
@@ -54,6 +54,10 @@
 )
 
 target_link_libraries(streams ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${ICONV_LIBRARIES})
+if(WIN32)
+    target_link_libraries(streams kdewin32)
+endif(WIN32)
+
 if(NOT WIN32)
   configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libstreams.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libstreams.pc)
 endif(NOT WIN32)
Index: strigi/config.h.cmake
===================================================================
--- strigi/config.h.cmake	(revision 768525)
+++ strigi/config.h.cmake	(working copy)
@@ -105,6 +105,8 @@
 #define PATH_SEPARATOR ":"
 #endif
 
+#ifndef HAVE_SYS_STAT_H
+
 #ifndef S_ISREG
     #define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
 #endif
@@ -133,6 +135,8 @@
 # define		S_IXOTH 0000001/* execute/search permission, other */
 #endif
 
+#endif /* !HAVE_SYS_STAT_H */
+
 // set sleep time
 #ifdef HAVE_NANOSLEEP
     #define strigi_nanosleep(nanoseconds) struct timespec sleeptime; sleeptime.tv_sec = 0; sleeptime.tv_nsec = nanoseconds; nanosleep(&sleeptime, 0);
@@ -140,7 +144,10 @@
 
 
 #ifdef _MSC_VER
+
+#ifndef HAVE_SLEEP
 	#define sleep(x) Sleep(x*1000)
+#endif
 	
 	#ifndef strigi_nanosleep
 	    #define strigi_nanosleep(nanoseconds) Sleep(nanoseconds/1000000)