/// <summary> /// Call back method which is called when sync event occurs /// </summary> /// <param name="args">Simias event details</param> private void OnSyncEvent(SimiasEventArgs args) { try { if (enabled) { CollectionSyncEventArgs cArgs = args as CollectionSyncEventArgs; if (cArgs != null) { if (CollectionSync != null) { Delegate[] cbList = CollectionSync.GetInvocationList(); foreach (CollectionSyncEventHandler cb in cbList) { try { cb(cArgs); } catch (Exception ex) { logger.Debug(ex, "Delegate {0}.{1} failed", cb.Target, cb.Method); CollectionSync -= cb; } } } } else { FileSyncEventArgs fArgs = args as FileSyncEventArgs; if (fArgs != null) { if (FileSync != null) { Delegate[] cbList = FileSync.GetInvocationList(); foreach (FileSyncEventHandler cb in cbList) { try { cb(fArgs); } catch (Exception ex) { logger.Debug(ex, "Delegate {0}.{1} failed", cb.Target, cb.Method); FileSync -= cb; } } } } } } } catch (Exception ex) { new SimiasException(args.ToString(), ex); } }
/// <summary> /// Callback used to indicate that a file is being synchronized. /// </summary> /// <param name="args">Arguments that give information about the file.</param> private void FileSyncEventCallback(FileSyncEventArgs args) { try { // Send the event to the client. byte[] buffer = new IProcEventData(args).ToBuffer(); eventSocket.BeginSend(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(EventSendComplete), this); } catch (Exception e) { DisposeSubscribers(); log.Error(e, String.Format("{0} : Error processing FileSyncEventCallback event for client.", port)); } }
private void SimiasEventSyncFileHandler(SimiasEventArgs args) { try { FileSyncEventArgs fileSyncArgs = args as FileSyncEventArgs; lock (FileEventQueue) { FileEventQueue.Enqueue(fileSyncArgs); FileEventFired.WakeupMain(); } } catch (Exception e) { if (printErrors) { Debug.PrintLine("Exception in SimiasEventSyncFileHandler(): " + e.Message); Debug.PrintLine(e.StackTrace); } } }
public void HandleFileSyncEvent(FileSyncEventArgs args) { if (args.SizeRemaining == args.SizeToSync) { if (!args.Direction.Equals(Simias.Client.Event.Direction.Local)) { if(SyncBar == null) { SyncBar = new ProgressBar(); SyncBar.Orientation = Gtk.ProgressBarOrientation.LeftToRight; SyncBar.PulseStep = .01; MainStatusBar.PackEnd(SyncBar, false, true, 0); } SyncBar.Fraction = 0; SyncBar.Show(); } switch (args.ObjectType) { case ObjectType.File: if (args.Delete) UpdateStatus(string.Format( Util.GS("Deleting file: {0}"), args.Name)); else { switch (args.Direction) { case Simias.Client.Event.Direction.Uploading: UpdateStatus(string.Format( Util.GS("Uploading file: {0}"), args.Name)); break; case Simias.Client.Event.Direction.Downloading: UpdateStatus(string.Format( Util.GS("Downloading file: {0}"), args.Name)); break; case Simias.Client.Event.Direction.Local: UpdateStatus(string.Format( Util.GS("Found changes in file: {0}"), args.Name)); break; default: UpdateStatus(string.Format( Util.GS("Synchronizing file: {0}"), args.Name)); break; } } break; case ObjectType.Directory: if (args.Delete) UpdateStatus(string.Format( Util.GS("Deleting directory: {0}"), args.Name)); else { switch (args.Direction) { case Simias.Client.Event.Direction.Uploading: UpdateStatus(string.Format( Util.GS("Uploading directory: {0}"), args.Name)); break; case Simias.Client.Event.Direction.Downloading: UpdateStatus(string.Format( Util.GS("Downloading directory: {0}"), args.Name)); break; case Simias.Client.Event.Direction.Local: UpdateStatus(string.Format( Util.GS("Found changes in directory: {0}"), args.Name)); break; default: UpdateStatus(string.Format( Util.GS("Synchronizing directory: {0}"), args.Name)); break; } } break; case ObjectType.Unknown: UpdateStatus(string.Format( Util.GS("Deleting on server: {0}"), args.Name)); break; } } else { if (SyncBar != null) { SyncBar.Show(); if (args.SizeToSync > 0) { SyncBar.Fraction = (((double)args.SizeToSync) - ((double)args.SizeRemaining)) / ((double)args.SizeToSync); } else SyncBar.Fraction = 1; } } }
private void syncFile(FileSyncEventArgs syncEventArgs) { try { syncAnimateTimer.Start(); syncToServer = syncEventArgs.Direction == Direction.Uploading; string message = null; switch (syncEventArgs.Status) { case SyncStatus.Success: { if (syncEventArgs.SizeRemaining == syncEventArgs.SizeToSync) { shellNotifyIcon.Text = resourceManager.GetString("iFolderServices") + "\n" + string.Format(resourceManager.GetString(syncEventArgs.Direction == Direction.Uploading ? "uploading" : "downloading"), syncEventArgs.Name); switch (syncEventArgs.ObjectType) { case ObjectType.File: if (syncEventArgs.Delete) { message = string.Format(resourceManager.GetString("deleteClientFile"), syncEventArgs.Name); } else if (syncEventArgs.SizeToSync < syncEventArgs.Size) { int savings = (int)((1 - ((double)syncEventArgs.SizeToSync / (double)syncEventArgs.Size)) * 100); message = string.Format(resourceManager.GetString(syncEventArgs.Direction == Direction.Uploading ? "uploadDeltaSyncFile" : "downloadDeltaSyncFile"), syncEventArgs.Name, savings); } else { switch (syncEventArgs.Direction) { case Direction.Uploading: message = string.Format(resourceManager.GetString("uploadFile"), syncEventArgs.Name); break; case Direction.Downloading: message = string.Format(resourceManager.GetString("downloadFile"), syncEventArgs.Name); break; case Direction.Local: message = string.Format(resourceManager.GetString("localFile"), syncEventArgs.Name); break; default: message = string.Format(resourceManager.GetString("syncingFile"), syncEventArgs.Name); break; } } break; case ObjectType.Directory: if (syncEventArgs.Delete) { message = string.Format(resourceManager.GetString("deleteClientDir"), syncEventArgs.Name); } else { switch (syncEventArgs.Direction) { case Direction.Uploading: message = string.Format(resourceManager.GetString("uploadDir"), syncEventArgs.Name); break; case Direction.Downloading: message = string.Format(resourceManager.GetString("downloadDir"), syncEventArgs.Name); break; case Direction.Local: message = string.Format(resourceManager.GetString("localDir"), syncEventArgs.Name); break; default: message = string.Format(resourceManager.GetString("syncingDir"), syncEventArgs.Name); break; } } break; case ObjectType.Unknown: message = string.Format(resourceManager.GetString("deleteUnknown"), syncEventArgs.Name); break; } } break; } case SyncStatus.UpdateConflict: case SyncStatus.FileNameConflict: message = string.Format(resourceManager.GetString("conflictFailure"), syncEventArgs.Name); errorSyncingCurrentCollection = true; infolog.AddMessageToLog(syncEventArgs.TimeStamp, message); break; case SyncStatus.Policy: message = string.Format(resourceManager.GetString("policyFailure"), syncEventArgs.Name); errorSyncingCurrentCollection = true; infolog.AddMessageToLog(syncEventArgs.TimeStamp, message); break; case SyncStatus.Access: message = string.Format(resourceManager.GetString("accessFailure"), syncEventArgs.Name); errorSyncingCurrentCollection = true; infolog.AddMessageToLog(syncEventArgs.TimeStamp, message); break; case SyncStatus.Locked: message = string.Format(resourceManager.GetString("lockFailure"), syncEventArgs.Name); errorSyncingCurrentCollection = true; infolog.AddMessageToLog(syncEventArgs.TimeStamp, message); break; case SyncStatus.PolicyQuota: if (!collectionsNotified.Contains(syncEventArgs.CollectionID)) { collectionsNotified.Add(syncEventArgs.CollectionID, null); string title = string.Format(resourceManager.GetString("quotaFailureTitle"), currentSyncCollectionName); notifyType = NotifyType.SyncError; shellNotifyIcon.DisplayBalloonTooltip(title, resourceManager.GetString("quotaFailureInfo"), BalloonType.Error); } message = string.Format(resourceManager.GetString("quotaFailure"), syncEventArgs.Name); errorSyncingCurrentCollection = true; infolog.AddMessageToLog(syncEventArgs.TimeStamp, message); break; case SyncStatus.PolicySize: message = string.Format(resourceManager.GetString("policySizeFailure"), syncEventArgs.Name); errorSyncingCurrentCollection = true; shellNotifyIcon.DisplayBalloonTooltip(string.Format(resourceManager.GetString("quotaFailureTitle"), currentSyncCollectionName), string.Format(resourceManager.GetString("policySizeFailure"), syncEventArgs.Name), BalloonType.Error); infolog.AddMessageToLog(syncEventArgs.TimeStamp, message); break; case SyncStatus.PolicyType: message = string.Format(resourceManager.GetString("policyTypeFailure"), syncEventArgs.Name); if (!(syncEventArgs.Name.EndsWith("thumbs.db") || syncEventArgs.Name.EndsWith("Thumbs.db"))) { errorSyncingCurrentCollection = true; infolog.AddMessageToLog(syncEventArgs.TimeStamp, message); } notifyType = NotifyType.SyncError; if (Preferences.HidePolicyVoilationNotification) { shellNotifyIcon.DisplayBalloonTooltip(string.Format(resourceManager.GetString("quotaFailureTitle"), currentSyncCollectionName), string.Format(resourceManager.GetString("policyTypeFailure"), syncEventArgs.Name), BalloonType.Error); } break; case SyncStatus.DiskFull: message = string.Format(syncToServer ? resourceManager.GetString("serverDiskFullFailure") : resourceManager.GetString("clientDiskFullFailure"), syncEventArgs.Name); errorSyncingCurrentCollection = true; infolog.AddMessageToLog(syncEventArgs.TimeStamp, message ); break; case SyncStatus.ReadOnly: if (!collectionsNotified.Contains(syncEventArgs.CollectionID)) { collectionsNotified.Add(syncEventArgs.CollectionID, null); string title = string.Format(resourceManager.GetString("quotaFailureTitle"), currentSyncCollectionName); notifyType = NotifyType.SyncError; shellNotifyIcon.DisplayBalloonTooltip(title, resourceManager.GetString("readOnlyFailureInfo"), BalloonType.Error); } message = string.Format(resourceManager.GetString("readOnlyFailure"), syncEventArgs.Name); errorSyncingCurrentCollection = true; infolog.AddMessageToLog(syncEventArgs.TimeStamp, message); break; case SyncStatus.PathTooLong: if (syncEventArgs.Direction == Direction.Downloading) { syncLog.AddMessageToLog(syncEventArgs.TimeStamp, string.Format("Path is too long for the file \"{0}\" to be downloaded.", syncEventArgs.Name)); } break; case SyncStatus.Busy: syncLog.AddMessageToLog(syncEventArgs.TimeStamp, string.Format("Could not synchronize because the server is busy: {0}", syncEventArgs.Name)); break; case SyncStatus.ClientError: syncLog.AddMessageToLog(syncEventArgs.TimeStamp, string.Format("Client sent bad data and could not synchronize: {0}", syncEventArgs.Name)); break; case SyncStatus.InUse: syncLog.AddMessageToLog(syncEventArgs.TimeStamp, string.Format("Could not synchronize because this file is in use: {0}", syncEventArgs.Name)); break; case SyncStatus.ServerFailure: syncLog.AddMessageToLog(syncEventArgs.TimeStamp, string.Format("Updating the metadata for this file failed: {0}", syncEventArgs.Name)); break; default: message = string.Format(resourceManager.GetString("genericFailure"), syncEventArgs.Name); errorSyncingCurrentCollection = true; infolog.AddMessageToLog(syncEventArgs.TimeStamp, message); break; } syncLog.AddMessageToLog(syncEventArgs.TimeStamp, message); } catch { } }
private void syncFile(FileSyncEventArgs syncEventArgs) { try { progressBar1.Visible = syncEventArgs.SizeToSync > 0; progressBar1.Value = 0; progressBar1.Maximum = 200; progressBar1.Value = syncEventArgs.SizeToSync > 0 ? (int)(((syncEventArgs.SizeToSync - syncEventArgs.SizeRemaining) * 200) / syncEventArgs.SizeToSync) : progressBar1.Maximum; if (startSync || (objectsToSync <= 0)) { startSync = false; SyncSize syncSize = ifWebService.CalculateSyncSize(syncEventArgs.CollectionID); objectsToSync = syncSize.SyncNodeCount; } if (!syncEventArgs.Direction.Equals(Direction.Local)) { lock (ht) { TileListViewItem tlvi = (TileListViewItem)ht[syncEventArgs.CollectionID]; if (tlvi != null) { if (objectsToSync != 0) { tlvi.Status = string.Format(TrayApp.Properties.Resources.statusSyncingItems, objectsToSync--); } } } } switch (syncEventArgs.ObjectType) { case ObjectType.File: if (syncEventArgs.Delete) { statusBar1.Text = string.Format(TrayApp.Properties.Resources.deleteClientFile, syncEventArgs.Name); } else { switch (syncEventArgs.Direction) { case Direction.Uploading: statusBar1.Text = string.Format(TrayApp.Properties.Resources.uploadFile, syncEventArgs.Name); break; case Direction.Downloading: statusBar1.Text = string.Format(TrayApp.Properties.Resources.downloadFile, syncEventArgs.Name); break; case Direction.Local: statusBar1.Text = string.Format(TrayApp.Properties.Resources.localFile, syncEventArgs.Name); break; default: statusBar1.Text = string.Format(TrayApp.Properties.Resources.syncingFile, syncEventArgs.Name); break; } } break; case ObjectType.Directory: if (syncEventArgs.Delete) { statusBar1.Text = string.Format(TrayApp.Properties.Resources.deleteClientDir, syncEventArgs.Name); } else { switch (syncEventArgs.Direction) { case Direction.Uploading: statusBar1.Text = string.Format(TrayApp.Properties.Resources.uploadDir, syncEventArgs.Name); break; case Direction.Downloading: statusBar1.Text = string.Format(TrayApp.Properties.Resources.downloadDir, syncEventArgs.Name); break; case Direction.Local: statusBar1.Text = string.Format(TrayApp.Properties.Resources.localDir, syncEventArgs.Name); break; default: statusBar1.Text = string.Format(TrayApp.Properties.Resources.syncingDir, syncEventArgs.Name); break; } } break; case ObjectType.Unknown: statusBar1.Text = string.Format(TrayApp.Properties.Resources.deleteUnknown, syncEventArgs.Name); break; } } catch {} }
private void fileSync(FileSyncEventArgs fileSyncEventArgs) { try { if (fileSyncEventArgs.SizeRemaining == fileSyncEventArgs.SizeToSync) { if (startSync || (objectsToSync <= 0)) { startSync = false; SyncSize syncSize = ifWebService.CalculateSyncSize(currentiFolder.ID); objectsToSync = syncSize.SyncNodeCount; } objectCount.Text = objectsToSync.ToString(); objectsToSync--; } } catch {} }
private void OniFolderFileSyncEvent(object o, FileSyncEventArgs args) { if (args == null || args.CollectionID == null || args.Name == null) return; try { string message = null; switch (args.Status) { case SyncStatus.Success: if(args.SizeRemaining == args.SizeToSync) { switch(args.ObjectType) { case ObjectType.File: if(args.Delete) { message = string.Format(Util.GS( "Deleting file: {0}"), args.Name); } else if (args.Direction == Simias.Client.Event.Direction.Local) { message = string.Format( Util.GS("Found changes in file: {0}"), args.Name); } else if (args.SizeToSync < args.Size) { int savings = (int)((1 - ((double)args.SizeToSync / (double)args.Size)) * 100); if (args.Direction == Simias.Client.Event.Direction.Uploading) message = string.Format( Util.GS("Uploading file: {0}. Synchronizing changes only: {1}% savings."), args.Name, savings); else message = string.Format( Util.GS("Downloading file: {0}. Synchronizing changes only: {1}% savings."), args.Name, savings); } else { if (args.Direction == Simias.Client.Event.Direction.Uploading) message = string.Format( Util.GS("Uploading file: {0}"), args.Name); else message = string.Format( Util.GS("Downloading file: {0}"), args.Name); } break; case ObjectType.Directory: if (args.Delete) { message = string.Format( Util.GS("Deleting directory: {0}"), args.Name); } else if (args.Direction == Simias.Client.Event.Direction.Local) { message = string.Format( Util.GS("Found changes in directory: {0}"), args.Name); } else { if (args.Direction == Simias.Client.Event.Direction.Uploading) message = string.Format( Util.GS("Uploading directory: {0}"), args.Name); else message = string.Format( Util.GS("Downloading directory: {0}"), args.Name); } break; case ObjectType.Unknown: message = string.Format( Util.GS("Deleting on server: {0}"), args.Name); break; } } break; case SyncStatus.UpdateConflict: case SyncStatus.FileNameConflict: message = string.Format( Util.GS("Conflict occurred: {0}"), args.Name); break; case SyncStatus.Policy: message = string.Format( Util.GS("Policy prevented synchronization: {0}"), args.Name); break; case SyncStatus.Access: message = string.Format( Util.GS("Insuficient rights prevented synchronization: {0}"), args.Name); break; case SyncStatus.Locked: message = string.Format( Util.GS("Locked iFolder prevented synchronization: {0}"), args.Name); break; case SyncStatus.PolicyQuota: message = string.Format( Util.GS("Full iFolder prevented synchronization: {0}"), args.Name); break; case SyncStatus.PolicySize: message = string.Format( Util.GS("Size restriction policy prevented synchronization: {0}"), args.Name); break; case SyncStatus.PolicyType: message = string.Format( Util.GS("File type restriction policy prevented synchronization: {0}"), args.Name); break; case SyncStatus.DiskFull: if (args.Direction == Simias.Client.Event.Direction.Uploading) { message = string.Format( Util.GS("Insufficient disk space on the server prevented synchronization: {0}"), args.Name); } else { message = string.Format( Util.GS("Insufficient disk space on this computer prevented synchronization: {0}"), args.Name); } break; case SyncStatus.ReadOnly: message = string.Format( Util.GS("Read-only iFolder prevented synchronization: {0}"), args.Name); break; case SyncStatus.Busy: message = string.Format( Util.GS("Could not synchronize because the server is busy: {0}"), args.Name); break; case SyncStatus.ClientError: message = string.Format( Util.GS("Client sent bad data and could not synchronize: {0}"), args.Name); break; case SyncStatus.InUse: message = string.Format( Util.GS("Could not synchronize because this file is in use: {0}"), args.Name); break; case SyncStatus.ServerFailure: message = string.Format( Util.GS("Updating the metadata for this file failed: {0}"), args.Name); break; default: message = string.Format( Util.GS("iFolder failed synchronization: {0}"), args.Name); break; } if (message != null && message.Length > 0) LogMessage(message); } catch {} }
private void OniFolderFileSyncEvent(object o, FileSyncEventArgs args) { if (args == null || args.CollectionID == null || args.Name == null) return; try { if (args.ObjectType == ObjectType.File || args.ObjectType == ObjectType.Directory) { if (args.Direction == Simias.Client.Event.Direction.Uploading && currentIconAnimationDirection != 1) { gAppIcon.Pixbuf = UploadingPixbuf; currentIconAnimationDirection = 1; } else if (args.Direction == Simias.Client.Event.Direction.Downloading && currentIconAnimationDirection != -1) { gAppIcon.Pixbuf = DownloadingPixbuf; currentIconAnimationDirection = -1; } } } catch {} if (args.Status != SyncStatus.Success) { string message = null; switch(args.Status) { case SyncStatus.Success: if (synchronizationErrors.ContainsKey(args.CollectionID)) synchronizationErrors.Remove(args.CollectionID); break; case SyncStatus.UpdateConflict: case SyncStatus.FileNameConflict: break; case SyncStatus.Policy: if( (bool)ClientConfig.Get(ClientConfig.KEY_NOTIFY_POLICY_VOILATION) ) message = Util.GS("A policy prevented complete synchronization."); break; case SyncStatus.Access: message = Util.GS("Insuficient rights prevented complete synchronization."); break; case SyncStatus.Locked: message = Util.GS("The iFolder is locked."); break; case SyncStatus.PolicyQuota: message = Util.GS("The iFolder is full. Click here to view the Synchronization Log."); message = Util.GS("The iFolder is full.\n\nClick <a href=\"ShowSyncLog\">here</a> to view the Synchronization Log."); break; case SyncStatus.PolicySize: if( (bool)ClientConfig.Get(ClientConfig.KEY_NOTIFY_POLICY_VOILATION) ) message = Util.GS("A size restriction policy prevented complete synchronization."); break; case SyncStatus.PolicyType: if( (bool)ClientConfig.Get(ClientConfig.KEY_NOTIFY_POLICY_VOILATION) ) message = Util.GS("A file type restriction policy prevented complete synchronization."); break; case SyncStatus.DiskFull: if (args.Direction == Simias.Client.Event.Direction.Uploading) { message = Util.GS("Insufficient disk space on the server prevented complete synchronization."); } else { message = Util.GS("Insufficient disk space on this computer prevented complete synchronization."); } break; case SyncStatus.ReadOnly: message = Util.GS("You have Read-only access to this iFolder. Files that you place in this iFolder will not be synchronized.\n\nClick <a href=\"ShowSyncLog\">here</a> to view the Synchronization Log."); break; default: message = Util.GS("iFolder synchronization failed."); break; } if (message != null) { Hashtable collectionSyncErrors = null; Debug.PrintLine(String.Format("Synchronization errors: {0}, {1}, {2}", args.Name, message, args.CollectionID)); if (synchronizationErrors.ContainsKey(args.CollectionID)) { collectionSyncErrors = (Hashtable)synchronizationErrors[args.CollectionID]; Debug.PrintLine(String.Format("collection sync errors exist: {0}", collectionSyncErrors.Count)); } else { collectionSyncErrors = new Hashtable(); synchronizationErrors[args.CollectionID] = collectionSyncErrors; } if (!collectionSyncErrors.ContainsKey(args.Status)) { collectionSyncErrors[args.Status] = message; Debug.PrintLine(String.Format("collection sync error count: {0}", collectionSyncErrors.Count)); } } } }
private void OniFolderFileSyncEvent(object o, FileSyncEventArgs args) { if (args == null || args.CollectionID == null || args.Name == null) return; try { if (args.ObjectType == ObjectType.File || args.ObjectType == ObjectType.Directory) { if (args.Direction == Simias.Client.Event.Direction.Uploading && currentIconAnimationDirection != 1) { gAppIcon.Pixbuf = UploadingPixbuf; currentIconAnimationDirection = 1; } else if (args.Direction == Simias.Client.Event.Direction.Downloading && currentIconAnimationDirection != -1) { gAppIcon.Pixbuf = DownloadingPixbuf; currentIconAnimationDirection = -1; } } } catch {} if (args.Status != SyncStatus.Success) { string message = null; switch(args.Status) { case SyncStatus.Success: if (synchronizationErrors.ContainsKey(args.CollectionID)) synchronizationErrors.Remove(args.CollectionID); break; case SyncStatus.UpdateConflict: case SyncStatus.FileNameConflict: break; case SyncStatus.Policy: if( (bool)ClientConfig.Get(ClientConfig.KEY_NOTIFY_POLICY_VOILATION) ) message = Util.GS("A policy prevented complete synchronization."); break; case SyncStatus.Access: if( (bool)ClientConfig.Get(ClientConfig.KEY_SHOW_PERMISSION_UNAVAILABLE) ) message = Util.GS("Insuficient rights prevented complete synchronization."); break; case SyncStatus.Locked: message = Util.GS("The iFolder is locked."); break; case SyncStatus.PolicyQuota: if( (bool)ClientConfig.Get(ClientConfig.KEY_SHOW_QUOTA_VIOLATION) || (bool)ClientConfig.Get(ClientConfig.KEY_SHOW_QUOTA_VIOLATION)) { message = Util.GS("The iFolder is full. Click here to view the Synchronization Log."); message = Util.GS("The iFolder is full.\n\nClick <a href=\"ShowSyncLog\">here</a> to view the Synchronization Log."); } break; case SyncStatus.PolicySize: if( (bool)ClientConfig.Get(ClientConfig.KEY_NOTIFY_POLICY_VOILATION) || (bool)ClientConfig.Get(ClientConfig.KEY_SHOW_FILE_SIZE_VOILATION) ) message = Util.GS("A size restriction policy prevented complete synchronization."); break; case SyncStatus.PolicyType: if( (bool)ClientConfig.Get(ClientConfig.KEY_NOTIFY_POLICY_VOILATION) || (bool)ClientConfig.Get(ClientConfig.KEY_SHOW_EXCLUSION_VOILATION)) message = Util.GS("A file type restriction policy prevented complete synchronization."); break; case SyncStatus.DiskFull: if( (bool)ClientConfig.Get(ClientConfig.KEY_SHOW_DISK_FULL) ) { if (args.Direction == Simias.Client.Event.Direction.Uploading) { message = Util.GS("Insufficient disk space on the server prevented complete synchronization."); } else { message = Util.GS("Insufficient disk space on this computer prevented complete synchronization."); } } break; case SyncStatus.ReadOnly: if( (bool)ClientConfig.Get(ClientConfig.KEY_SHOW_PERMISSION_UNAVAILABLE) ) { message = Util.GS("You have Read-only access to this iFolder. Files that you place in this iFolder will not be synchronized.\n\nClick <a href=\"ShowSyncLog\">here</a> to view the Synchronization Log."); } break; case SyncStatus.IOError: if (args.Direction == Simias.Client.Event.Direction.Uploading) message = Util.GS("Unable to read files from the folder. Verify the permissions on your local folder."); else message = Util.GS("Unable to write files in the folder. Verify the permissions on your local folder."); break; case SyncStatus.PathTooLong: if( (bool)ClientConfig.Get(ClientConfig.KEY_SHOW_EXCEEDS_PATH_SIZE) ) { if (args.Direction == Simias.Client.Event.Direction.Downloading) message = string.Format(Util.GS("Cannot download the file (0) because the file path exceeds the optimal limit."),args.Name); } break; default: message = Util.GS("iFolder synchronization failed."); break; } if (message != null) { Hashtable collectionSyncErrors = null; Debug.PrintLine(String.Format("Synchronization errors: {0}, {1}, {2}", args.Name, message, args.CollectionID)); if (synchronizationErrors.ContainsKey(args.CollectionID)) { collectionSyncErrors = (Hashtable)synchronizationErrors[args.CollectionID]; Debug.PrintLine(String.Format("collection sync errors exist: {0}", collectionSyncErrors.Count)); } else { collectionSyncErrors = new Hashtable(); synchronizationErrors[args.CollectionID] = collectionSyncErrors; } if (!collectionSyncErrors.ContainsKey(args.Status)) { collectionSyncErrors[args.Status] = message; Debug.PrintLine(String.Format("collection sync error count: {0}", collectionSyncErrors.Count)); } } } }
private void OniFolderFileSyncEvent(object o, FileSyncEventArgs args) { if (args == null || args.CollectionID == null || args.Name == null) return; if (args.SizeRemaining == args.SizeToSync) { if (startingSync || (objectsToSync <= 0)) { startingSync = false; try { SyncSize syncSize = ifws.CalculateSyncSize(args.CollectionID); objectsToSync = syncSize.SyncNodeCount; } catch(Exception e) { objectsToSync = 1; } } if (!args.Direction.Equals(Simias.Client.Event.Direction.Local)) { if (objectsToSync <= 0) objectsToSync = 0; else objectsToSync--; TreeIter iter = TreeIter.Zero; iFolderHolder ifHolder = null; if (ifolderIters.ContainsKey(args.CollectionID)) { iter = (TreeIter)ifolderIters[args.CollectionID]; ifHolder = (iFolderHolder)iFolderListStore.GetValue(iter, 0); } if (ifHolder != null) { if (ifHolder.State != iFolderState.Synchronizing) ifHolder.State = iFolderState.Synchronizing; ifHolder.ObjectsToSync = objectsToSync; TreePath path = iFolderListStore.GetPath(iter); if (path != null) { iFolderChangedHandler changedHandler = new iFolderChangedHandler(path, iter, iFolderListStore); GLib.Idle.Add(changedHandler.IdleHandler); } } } } if (args.Status != SyncStatus.Success) bFileSyncFailed = true; }
/// <summary> /// On iFolder File Sync Event /// </summary> private void OniFolderFileSyncEvent(object o, FileSyncEventArgs args) { bool showSyncLog = false; if (args == null || args.CollectionID == null || args.Name == null) { return; // Prevent a null object exception } try { string message = null; switch (args.Status) { case SyncStatus.Success: if (args.SizeRemaining == args.SizeToSync) { switch (args.ObjectType) { case ObjectType.File: if (args.Delete) { message = string.Format(Util.GS( "Deleting file: {0}"), args.Name); } else if (args.Direction == Simias.Client.Event.Direction.Local) { message = string.Format( Util.GS("Found changes in file: {0}"), args.Name); } else if (args.SizeToSync < args.Size) { // Note: Delta sync works on 4KB blocks, so you won't see delta // sync messages until files reach at least 4KB. int savings = (int)((1 - ((double)args.SizeToSync / (double)args.Size)) * 100); if (args.Direction == Simias.Client.Event.Direction.Uploading) { message = string.Format( Util.GS("Uploading file: {0}. Synchronizing changes only: {1}% savings."), args.Name, savings); } else { message = string.Format( Util.GS("Downloading file: {0}. Synchronizing changes only: {1}% savings."), args.Name, savings); } } else { if (args.Direction == Simias.Client.Event.Direction.Uploading) { message = string.Format( Util.GS("Uploading file: {0}"), args.Name); } else { message = string.Format( Util.GS("Downloading file: {0}"), args.Name); } } break; case ObjectType.Directory: if (args.Delete) { message = string.Format( Util.GS("Deleting directory: {0}"), args.Name); } else if (args.Direction == Simias.Client.Event.Direction.Local) { message = string.Format( Util.GS("Found changes in directory: {0}"), args.Name); } else { if (args.Direction == Simias.Client.Event.Direction.Uploading) { message = string.Format( Util.GS("Uploading directory: {0}"), args.Name); } else { message = string.Format( Util.GS("Downloading directory: {0}"), args.Name); } } break; case ObjectType.Unknown: message = string.Format( Util.GS("Deleting on server: {0}"), args.Name); break; } } break; case SyncStatus.UpdateConflict: case SyncStatus.FileNameConflict: message = string.Format( Util.GS("Conflict occurred: {0}"), args.Name); break; case SyncStatus.Policy: message = string.Format( Util.GS("Policy prevented synchronization: {0}"), args.Name); break; case SyncStatus.Access: message = string.Format( Util.GS("Insuficient rights prevented synchronization: {0}"), args.Name); break; case SyncStatus.Locked: message = string.Format( Util.GS("Locked iFolder prevented synchronization: {0}"), args.Name); break; case SyncStatus.PolicyQuota: message = string.Format( Util.GS("Full iFolder prevented synchronization: {0}"), args.Name); break; case SyncStatus.PolicySize: message = string.Format( Util.GS("Size restriction policy prevented synchronization: {0}"), args.Name); break; case SyncStatus.PolicyType: message = string.Format( Util.GS("File type restriction policy prevented synchronization: {0}"), args.Name); showSyncLog = true; break; case SyncStatus.DiskFull: if (args.Direction == Simias.Client.Event.Direction.Uploading) { message = string.Format( Util.GS("Insufficient disk space on the server prevented synchronization: {0}"), args.Name); } else { message = string.Format( Util.GS("Insufficient disk space on this computer prevented synchronization: {0}"), args.Name); } break; case SyncStatus.ReadOnly: message = string.Format( Util.GS("Read-only iFolder prevented synchronization: {0}"), args.Name); break; case SyncStatus.Busy: message = string.Format( Util.GS("Could not synchronize because the server is busy: {0}"), args.Name); break; case SyncStatus.ClientError: message = string.Format( Util.GS("Client sent bad data and could not synchronize: {0}"), args.Name); break; case SyncStatus.InUse: message = string.Format( Util.GS("Could not synchronize because this file is in use: {0}"), args.Name); break; case SyncStatus.ServerFailure: message = string.Format( Util.GS("Updating the metadata for this file failed: {0}"), args.Name); break; case SyncStatus.PathTooLong: if (args.Direction == Simias.Client.Event.Direction.Downloading) { message = string.Format(Util.GS("Cannot download the file (0) because the file path exceeds the optimal limit."), args.Name); } break; default: message = string.Format( Util.GS("iFolder failed synchronization: {0}"), args.Name); break; } if (message != null && message.Length > 0) { LogMessage(message); //auto pop-up for SyncLog window, based on below flag if (showSyncLog && (bool)ClientConfig.Get(ClientConfig.KEY_SHOW_SYNC_LOG)) { Util.ShowLogWindow(simiasManager); } } } catch {} }
private void syncFile(FileSyncEventArgs syncEventArgs) { try { if (syncEventArgs.SizeRemaining == syncEventArgs.SizeToSync) { progressBar1.Visible = syncEventArgs.SizeToSync > 0; progressBar1.Value = 0; progressBar1.Maximum = 200; if (startSync || (objectsToSync <= 0)) { startSync = false; SyncSize syncSize = ifWebService.CalculateSyncSize(syncEventArgs.CollectionID); objectsToSync = syncSize.SyncNodeCount; } if (!syncEventArgs.Direction.Equals(Direction.Local)) { lock (ht) { ListViewItem lvi = (ListViewItem)ht[syncEventArgs.CollectionID]; if (lvi != null) { lvi.SubItems[2].Text = string.Format(resourceManager.GetString("statusSyncingItems"), objectsToSync--); } } } switch (syncEventArgs.ObjectType) { case ObjectType.File: if (syncEventArgs.Delete) { statusBar1.Text = string.Format(resourceManager.GetString("deleteClientFile"), syncEventArgs.Name); } else { switch (syncEventArgs.Direction) { case Direction.Uploading: statusBar1.Text = string.Format(resourceManager.GetString("uploadFile"), syncEventArgs.Name); break; case Direction.Downloading: statusBar1.Text = string.Format(resourceManager.GetString("downloadFile"), syncEventArgs.Name); break; case Direction.Local: statusBar1.Text = string.Format(resourceManager.GetString("localFile"), syncEventArgs.Name); break; default: statusBar1.Text = string.Format(resourceManager.GetString("syncingFile"), syncEventArgs.Name); break; } } break; case ObjectType.Directory: if (syncEventArgs.Delete) { statusBar1.Text = string.Format(resourceManager.GetString("deleteClientDir"), syncEventArgs.Name); } else { switch (syncEventArgs.Direction) { case Direction.Uploading: statusBar1.Text = string.Format(resourceManager.GetString("uploadDir"), syncEventArgs.Name); break; case Direction.Downloading: statusBar1.Text = string.Format(resourceManager.GetString("downloadDir"), syncEventArgs.Name); break; case Direction.Local: statusBar1.Text = string.Format(resourceManager.GetString("localDir"), syncEventArgs.Name); break; default: statusBar1.Text = string.Format(resourceManager.GetString("syncingDir"), syncEventArgs.Name); break; } } break; case ObjectType.Unknown: statusBar1.Text = string.Format(resourceManager.GetString("deleteUnknown"), syncEventArgs.Name); break; } } else { statusBar1.Text = syncEventArgs.Name; progressBar1.Value = syncEventArgs.SizeToSync > 0 ? (int)(((syncEventArgs.SizeToSync - syncEventArgs.SizeRemaining) * 200) / syncEventArgs.SizeToSync) : progressBar1.Maximum; } } catch {} }
private void OniFolderFileSyncEvent(object o, FileSyncEventArgs args) { if (args == null || args.CollectionID == null || args.Name == null) return; if (args.SizeRemaining == args.SizeToSync) { if (startingSync || (objectsToSync <= 0)) { startingSync = false; try { SyncSize syncSize = ifws.CalculateSyncSize(args.CollectionID); objectsToSync = syncSize.SyncNodeCount; } catch(Exception e) { objectsToSync = 1; } } if (!args.Direction.Equals(Simias.Client.Event.Direction.Local)) { if (objectsToSync <= 0) objectsToSync = 0; else objectsToSync--; TreeIter iter = TreeIter.Zero; iFolderHolder ifHolder = null; if (ifolderIters.ContainsKey(args.CollectionID)) { iter = (TreeIter)ifolderIters[args.CollectionID]; ifHolder = (iFolderHolder)iFolderListStore.GetValue(iter, 0); } if (ifHolder != null) { ifHolder.ObjectsToSync = objectsToSync; TreePath path = iFolderListStore.GetPath(iter); if (path != null) iFolderListStore.EmitRowChanged(path, iter); else Console.WriteLine("*** SOMETHING WENT BAD IN iFolderData.OniFolderFileSyncEvent() ***"); } } } }
private void OniFolderFileSyncEvent(object o, FileSyncEventArgs args) { if (args == null || args.CollectionID == null || args.Name == null) return; try { if (args.Direction == Simias.Client.Event.Direction.Uploading && bCollectionIsSynchronizing && currentIconAnimationDirection != 1) { gAppIcon.FromAnimation = UploadingPixbuf; currentIconAnimationDirection = 1; } else if (args.Direction == Simias.Client.Event.Direction.Downloading && bCollectionIsSynchronizing && currentIconAnimationDirection != -1) { gAppIcon.FromAnimation = DownloadingPixbuf; currentIconAnimationDirection = -1; } iFolderWindow ifwin = Util.GetiFolderWindow(); if(ifwin != null) ifwin.HandleFileSyncEvent(args); LogWindow logwin = Util.GetLogWindow(simiasManager); if(logwin != null) logwin.HandleFileSyncEvent(args); } catch {} if (args.Status != SyncStatus.Success) { string message = null; switch(args.Status) { case SyncStatus.Success: if (synchronizationErrors.ContainsKey(args.CollectionID)) synchronizationErrors.Remove(args.CollectionID); break; case SyncStatus.PolicyQuota: message = Util.GS("The iFolder is full.\n\nClick <a href=\"ShowSyncLog\">here</a> to view the Synchronization Log."); break; case SyncStatus.ReadOnly: message = Util.GS("You have Read-only access to this iFolder. Files that you place in this iFolder will not be synchronized.\n\nClick <a href=\"ShowSyncLog\">here</a> to view the Synchronization Log."); break; } if (message != null) { Hashtable collectionSyncErrors = null; if (synchronizationErrors.ContainsKey(args.CollectionID)) { collectionSyncErrors = (Hashtable)synchronizationErrors[args.CollectionID]; } else { collectionSyncErrors = new Hashtable(); synchronizationErrors[args.CollectionID] = collectionSyncErrors; } if (!collectionSyncErrors.ContainsKey(args.Status)) { collectionSyncErrors[args.Status] = message; } } } }
private void syncFile(FileSyncEventArgs syncEventArgs) { try { syncAnimateTimer.Start(); syncToServer = syncEventArgs.Direction == Direction.Uploading; string message = null; switch (syncEventArgs.Status) { case SyncStatus.Success: { if (syncEventArgs.SizeRemaining == syncEventArgs.SizeToSync) { shellNotifyIcon.Text = resourceManager.GetString("iFolderServices") + "\n" + string.Format(resourceManager.GetString(syncEventArgs.Direction == Direction.Uploading ? "uploading" : "downloading") , syncEventArgs.Name); switch (syncEventArgs.ObjectType) { case ObjectType.File: if (syncEventArgs.Delete) { message = string.Format(resourceManager.GetString("deleteClientFile"), syncEventArgs.Name); } else if (syncEventArgs.SizeToSync < syncEventArgs.Size) { int savings = (int)((1 - ((double)syncEventArgs.SizeToSync / (double)syncEventArgs.Size)) * 100); message = string.Format(resourceManager.GetString(syncEventArgs.Direction == Direction.Uploading ? "uploadDeltaSyncFile" : "downloadDeltaSyncFile"), syncEventArgs.Name, savings); } else { switch (syncEventArgs.Direction) { case Direction.Uploading: message = string.Format(resourceManager.GetString("uploadFile"), syncEventArgs.Name); break; case Direction.Downloading: message = string.Format(resourceManager.GetString("downloadFile"), syncEventArgs.Name); break; case Direction.Local: message = string.Format(resourceManager.GetString("localFile"), syncEventArgs.Name); break; default: message = string.Format(resourceManager.GetString("syncingFile"), syncEventArgs.Name); break; } } break; case ObjectType.Directory: if (syncEventArgs.Delete) { message = string.Format(resourceManager.GetString("deleteClientDir"), syncEventArgs.Name); } else { switch (syncEventArgs.Direction) { case Direction.Uploading: message = string.Format(resourceManager.GetString("uploadDir"), syncEventArgs.Name); break; case Direction.Downloading: message = string.Format(resourceManager.GetString("downloadDir"), syncEventArgs.Name); break; case Direction.Local: message = string.Format(resourceManager.GetString("localDir"), syncEventArgs.Name); break; default: message = string.Format(resourceManager.GetString("syncingDir"), syncEventArgs.Name); break; } } break; case ObjectType.Unknown: message = string.Format(resourceManager.GetString("deleteUnknown"), syncEventArgs.Name); break; } } break; } case SyncStatus.UpdateConflict: case SyncStatus.FileNameConflict: message = string.Format(resourceManager.GetString("conflictFailure"), syncEventArgs.Name); break; case SyncStatus.Policy: message = string.Format(resourceManager.GetString("policyFailure"), syncEventArgs.Name); break; case SyncStatus.Access: message = string.Format(resourceManager.GetString("accessFailure"), syncEventArgs.Name); break; case SyncStatus.Locked: message = string.Format(resourceManager.GetString("lockFailure"), syncEventArgs.Name); break; case SyncStatus.PolicyQuota: if (!collectionsNotified.Contains(syncEventArgs.CollectionID)) { collectionsNotified.Add(syncEventArgs.CollectionID, null); string title = string.Format(resourceManager.GetString("quotaFailureTitle"), currentSyncCollectionName); notifyType = NotifyType.SyncError; shellNotifyIcon.DisplayBalloonTooltip(title, resourceManager.GetString("quotaFailureInfo"), BalloonType.Error); } message = string.Format(resourceManager.GetString("quotaFailure"), syncEventArgs.Name); break; case SyncStatus.PolicySize: message = string.Format(resourceManager.GetString("policySizeFailure"), syncEventArgs.Name); break; case SyncStatus.PolicyType: message = string.Format(resourceManager.GetString("policyTypeFailure"), syncEventArgs.Name); break; case SyncStatus.DiskFull: message = string.Format(syncToServer ? resourceManager.GetString("serverDiskFullFailure") : resourceManager.GetString("clientDiskFullFailure"), syncEventArgs.Name); break; case SyncStatus.ReadOnly: if (!collectionsNotified.Contains(syncEventArgs.CollectionID)) { collectionsNotified.Add(syncEventArgs.CollectionID, null); string title = string.Format(resourceManager.GetString("quotaFailureTitle"), currentSyncCollectionName); notifyType = NotifyType.SyncError; shellNotifyIcon.DisplayBalloonTooltip(title, resourceManager.GetString("readOnlyFailureInfo"), BalloonType.Error); } message = string.Format(resourceManager.GetString("readOnlyFailure"), syncEventArgs.Name); break; default: message = string.Format(resourceManager.GetString("genericFailure"), syncEventArgs.Name); break; } syncLog.AddMessageToLog(syncEventArgs.TimeStamp, message); } catch {} }