Overlay Icons: Improve OS X version, improve general feedback

Now the update phase of the syncing algorithm pushes stuff the notification socket too.
This commit is contained in:
Markus Goetz 2014-08-27 19:05:26 +02:00
parent a73316306d
commit 2f34b046d0
8 changed files with 56 additions and 14 deletions

View file

@ -18,6 +18,7 @@
{
NSMutableDictionary* _fileNamesCache;
BOOL _fileIconsEnabled;
BOOL _hasChangedContent;
NSNumber *_icnOk;
NSNumber *_icnSync;

View file

@ -31,6 +31,7 @@ static ContentManager* sharedInstance = nil;
{
_fileNamesCache = [[NSMutableDictionary alloc] init];
_fileIconsEnabled = TRUE;
_hasChangedContent = TRUE;
NSString *base = @"/Applications/owncloud.app/Contents/Resources/icons/";
@ -107,14 +108,18 @@ static ContentManager* sharedInstance = nil;
}
NSString* normalizedPath = [path decomposedStringWithCanonicalMapping];
[_fileNamesCache setObject:res forKey:normalizedPath];
// NSLog(@"SET value %d", [res intValue]);
[self repaintAllWindows];
if (![_fileNamesCache objectForKey:normalizedPath] || ![[_fileNamesCache objectForKey:normalizedPath] isEqualToString:res]) {
[_fileNamesCache setObject:res forKey:normalizedPath];
// NSLog(@"SET value %d", [res intValue]);
_hasChangedContent = YES;
[self performSelector:@selector(repaintAllWindowsIfNeeded) withObject:0 afterDelay:1.0]; // 1 sec
}
}
- (NSNumber*)iconByPath:(NSString*)path isDirectory:(BOOL)isDir
{
//NSLog(@"%@ %@", NSStringFromSelector(_cmd), path);
if (!_fileIconsEnabled)
{
NSLog(@"Icons are NOT ENABLED!");
@ -151,6 +156,7 @@ static ContentManager* sharedInstance = nil;
// it clears the entries from the hash to make it call again home to mirall.
- (void)clearFileNameCacheForPath:(NSString*)path
{
NSLog(@"%@", NSStringFromSelector(_cmd));
NSMutableArray *keysToDelete = [NSMutableArray array];
if( path != nil ) {
@ -170,9 +176,6 @@ static ContentManager* sharedInstance = nil;
if( [keysToDelete count] > 0 ) {
NSLog( @"Entries to delete: %d", [keysToDelete count]);
[_fileNamesCache removeObjectsForKeys:keysToDelete];
[self repaintAllWindows];
}
}
@ -195,8 +198,20 @@ static ContentManager* sharedInstance = nil;
[self repaintAllWindows];
}
- (void)repaintAllWindowsIfNeeded
{
if (!_hasChangedContent) {
NSLog(@"%@ Repaint scheduled but not needed", NSStringFromSelector(_cmd));
return;
}
_hasChangedContent = NO;
[self repaintAllWindows];
}
- (void)repaintAllWindows
{
NSLog(@"%@", NSStringFromSelector(_cmd));
NSArray* windows = [[NSApplication sharedApplication] windows];
for (int i = 0; i < [windows count]; i++)
@ -286,7 +301,7 @@ static ContentManager* sharedInstance = nil;
}
else
{
NSLog(@"LiferayNativityFinder: refreshing icon badges failed");
NSLog(@"OwnCloudFinder: refreshing icon badges failed");
return;
}
@ -297,6 +312,7 @@ static ContentManager* sharedInstance = nil;
- (void)setIcons:(NSDictionary*)iconDictionary filterByFolder:(NSString*)filterFolder
{
NSLog(@"%@", NSStringFromSelector(_cmd));
for (NSString* path in iconDictionary)
{
if (filterFolder && ![path hasPrefix:filterFolder])

View file

@ -136,9 +136,6 @@ static RequestManager* sharedInstance = nil;
[contentman setResultForPath:[chunks objectAtIndex:2] result:[chunks objectAtIndex:1]];
} else if( [[chunks objectAtIndex:0] isEqualToString:@"UPDATE_VIEW"] ) {
NSString *path = [chunks objectAtIndex:1];
[contentman clearFileNameCacheForPath:path];
[contentman repaintAllWindows];
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"REGISTER_PATH"] ) {
NSNumber *one = [NSNumber numberWithInt:1];
NSString *path = [chunks objectAtIndex:1];

View file

@ -600,6 +600,7 @@ void Folder::startSync(const QStringList &pathList)
connect(_engine.data(), SIGNAL(folderDiscovered(bool,QString)), this, SLOT(slotFolderDiscovered(bool,QString)));
connect(_engine.data(), SIGNAL(transmissionProgress(Progress::Info)), this, SLOT(slotTransmissionProgress(Progress::Info)));
connect(_engine.data(), SIGNAL(jobCompleted(SyncFileItem)), this, SLOT(slotJobCompleted(SyncFileItem)));
connect(_engine.data(), SIGNAL(syncItemDiscovered(SyncFileItem)), this, SLOT(slotSyncItemDiscovered(SyncFileItem)));
setDirtyNetworkLimits();
_engine->setSelectiveSyncBlackList(selectiveSyncBlackList());
@ -725,6 +726,11 @@ void Folder::slotJobCompleted(const SyncFileItem &item)
emit ProgressDispatcher::instance()->jobCompleted(alias(), item);
}
void Folder::slotSyncItemDiscovered(const SyncFileItem & item)
{
emit ProgressDispatcher::instance()->syncItemDiscovered(alias(), item);
}
void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction, bool *cancel)
{

View file

@ -164,6 +164,7 @@ private slots:
void slotFolderDiscovered(bool local, QString folderName);
void slotTransmissionProgress(const Progress::Info& pi);
void slotJobCompleted(const SyncFileItem&);
void slotSyncItemDiscovered(const SyncFileItem & item);
void slotPollTimerTimeout();
void etagRetreived(const QString &);

View file

@ -201,6 +201,8 @@ signals:
*/
void jobCompleted(const QString &folder, const SyncFileItem & item);
void syncItemDiscovered(const QString &folder, const SyncFileItem & item);
protected:
void setProgressInfo(const QString& folder, const Progress::Info& progress);

View file

@ -199,6 +199,8 @@ SocketApi::SocketApi(QObject* parent)
connect(FolderMan::instance(), SIGNAL(folderSyncStateChange(QString)), this, SLOT(slotUpdateFolderView(QString)));
connect(ProgressDispatcher::instance(), SIGNAL(jobCompleted(QString,SyncFileItem)),
SLOT(slotJobCompleted(QString,SyncFileItem)));
connect(ProgressDispatcher::instance(), SIGNAL(syncItemDiscovered(QString,SyncFileItem)),
this, SLOT(slotSyncItemDiscovered(QString,SyncFileItem)));
}
SocketApi::~SocketApi()
@ -318,8 +320,9 @@ void SocketApi::slotUpdateFolderView(const QString& alias)
void SocketApi::slotJobCompleted(const QString &folder, const SyncFileItem &item)
{
Folder *f = FolderMan::instance()->folder(folder);
if (!f)
if (!f) {
return;
}
const QString path = f->path() + item.destination();
@ -327,9 +330,24 @@ void SocketApi::slotJobCompleted(const QString &folder, const SyncFileItem &item
if (Progress::isWarningKind(item._status)) {
command = QLatin1String("ERROR");
}
if( Utility::isLinux() ) {
broadcastMessage(QLatin1String("BROADCAST"), path, command);
broadcastMessage(QLatin1String("STATUS"), path, command);
}
void SocketApi::slotSyncItemDiscovered(const QString &folder, const SyncFileItem &item)
{
if (item._instruction == CSYNC_INSTRUCTION_NONE) {
return;
}
Folder *f = FolderMan::instance()->folder(folder);
if (!f) {
return;
}
const QString path = f->path() + item.destination();
const QString command = QLatin1String("SYNC");
broadcastMessage(QLatin1String("STATUS"), path, command);
}

View file

@ -51,6 +51,7 @@ private slots:
void onLostConnection();
void slotReadSocket();
void slotJobCompleted(const QString &, const SyncFileItem &);
void slotSyncItemDiscovered(const QString &, const SyncFileItem &);
private:
void sendMessage(QTcpSocket* socket, const QString& message, bool doWait = false);