Browse Source

SocketAPI: Use Win32 function SHChangeNotify to notify Explorer.

Klaas Freitag 11 years ago
parent
commit
6cb8134690
3 changed files with 17 additions and 2 deletions
  1. 5 1
      src/mirall/socketapi.cpp
  2. 11 0
      src/mirall/utility.cpp
  3. 1 1
      src/mirall/utility.h

+ 5 - 1
src/mirall/socketapi.cpp

@@ -276,7 +276,11 @@ void SocketApi::slotUpdateFolderView(const QString& alias)
                 f->syncResult().status() == SyncResult::Problem ||
                 f->syncResult().status() == SyncResult::Error   ||
                 f->syncResult().status() == SyncResult::SetupError ) {
-            broadcastMessage(QLatin1String("UPDATE_VIEW"), f->path() );
+            if( Utility::isWindows() ) {
+                Utility::winShellChangeNotify( f->path() );
+            } else {
+                broadcastMessage(QLatin1String("UPDATE_VIEW"), f->path() );
+            }
         }
     }
 }

+ 11 - 0
src/mirall/utility.cpp

@@ -361,6 +361,17 @@ bool Utility::isLinux()
 #endif
 }
 
+void Utility::winShellChangeNotify( const QString& path )
+{
+#ifdef Q_OS_WIN
+    SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH | SHCNF_FLUSHNOWAIT,
+                   reinterpret_cast<const wchar_t *>(QDir::toNativeSeparators(path).utf16()), NULL );
+#else
+    qDebug() << Q_FUNC_INFO << " is not implemented on non Windows systems.";
+#endif
+}
+
+
 static const char STOPWATCH_END_TAG[] = "_STOPWATCH_END";
 
 void Utility::StopWatch::start()

+ 1 - 1
src/mirall/utility.h

@@ -59,7 +59,7 @@ namespace Utility
     OWNCLOUDSYNC_EXPORT QDateTime qDateTimeFromTime_t(qint64 t);
     OWNCLOUDSYNC_EXPORT qint64 qDateTimeToTime_t(const QDateTime &t);
 
-
+    OWNCLOUDSYNC_EXPORT void winShellChangeNotify( const QString& path );
 
     /**
      * @brief Convert milliseconds to HMS string.