// Execute list job. func (job *ListJob) Execute() []operations.ListProperty { defer dbus.UnInstallObject(job) var files []operations.ListProperty job.op.ListenProcessedAmount(func(size int64, unit operations.AmountUnit) { dbus.Emit(job, "ProcessedAmount", size, uint16(unit)) }) job.op.ListenProperty(func(property operations.ListProperty) { dbus.Emit(job, "EntryInfo", property) files = append(files, property) }) job.op.ListenDone(func(err error) { errMsg := "" if err != nil { errMsg = err.Error() } // time.Sleep(time.Microsecond * 200) dbus.Emit(job, "Done", errMsg) }) job.op.ListenAborted(func() { defer dbus.UnInstallObject(job) dbus.Emit(job, "Aborted") }) job.op.Execute() return files }
func (job *CopyJob) listenSignals() { job.op.ListenTotalAmount(func(amount int64, unit operations.AmountUnit) { dbus.Emit(job, "TotalAmount", amount, uint16(unit)) }) job.op.ListenProcessedAmount(func(amount int64, unit operations.AmountUnit) { dbus.Emit(job, "ProcessedAmount", amount, uint16(unit)) }) job.op.ListenPercent(func(percent int64) { dbus.Emit(job, "ProcessedPercent", percent) }) job.op.ListenCopying(func(srcURL string) { Log.Debug("copying", srcURL) dbus.Emit(job, "Copying", srcURL) }) job.op.ListenCreatingDir(func(dirURL string) { // TODO // dbus.Emit(job, "CreatingDir", dirURL) }) job.op.ListenCopyingMovingDone(func(srcURL string, destURL string) { }) job.op.ListenDone(func(err error) { defer dbus.UnInstallObject(job) errMsg := "" if err != nil { errMsg = err.Error() } dbus.Emit(job, "Done", errMsg) }) job.op.ListenAborted(func() { defer dbus.UnInstallObject(job) dbus.Emit(job, "Aborted") }) }
// Execute GetDefaultLaunchAppJob. func (job *GetDefaultLaunchAppJob) Execute() { job.op.ListenDone(func(err error) { defer dbus.UnInstallObject(job) if err != nil { dbus.Emit(job, "Done", err.Error()) return } app := job.op.Result().(*gio.AppInfo) info := &DefaultLaunchAppInfo{ Name: app.GetName(), Id: app.GetId(), // TODO: get icon. // Icon: getIconFromApp(app), } app.Unref() bInfos, err := json.Marshal(info) if err != nil { dbus.Emit(job, "Done", err.Error()) return } dbus.Emit(job, "DefaultLaunchAppInfo", string(bInfos)) dbus.Emit(job, "Done", "") }) job.op.Execute() }
func (job *GetAllLaunchAppsJob) Execute() { job.op.ListenDone(func(e error) { defer dbus.UnInstallObject(job) if e != nil { dbus.Emit(job, "Done", e.Error()) return } apps := job.op.Result().([]*gio.AppInfo) info := LaunchAppInfo{ Names: make([]string, len(apps)), Ids: make([]string, len(apps)), } for i, app := range apps { info.Names[i] = app.GetName() info.Ids[i] = app.GetId() // TODO: get icon // app.GetIcon() app.Unref() } bInfos, err := json.Marshal(info) if err != nil { dbus.Emit(job, "Done", err.Error()) return } dbus.Emit(job, "LaunchAppInfo", string(bInfos)) dbus.Emit(job, "Done", "") }) job.op.Execute() }
// Execute trash job. func (job *TrashJob) Execute() { job.op.ListenProcessedAmount(func(size int64, unit operations.AmountUnit) { dbus.Emit(job, "ProcessedAmount", size, uint16(unit)) }) job.op.ListenPercent(func(percent int64) { dbus.Emit(job, "ProcessedPercent", percent) }) job.op.ListenAborted(func() { defer dbus.UnInstallObject(job) dbus.Emit(job, "Aborted") }) job.op.ListenDone(func(err error) { dbus.Emit(job, "Done") }) // TODO: fill signals. defer dbus.UnInstallObject(job) job.op.Execute() }
// Execute chmod job. func (job *ChmodJob) Execute() { job.op.ListenDone(func(err error) { defer dbus.UnInstallObject(job) errMsg := "" if err != nil { errMsg = err.Error() } dbus.Emit(job, "Done", errMsg) }) job.op.Execute() }
// Execute stat job. func (job *StatJob) Execute() { job.op.ListenDone(func(err error) { defer dbus.UnInstallObject(job) if err != nil { dbus.Emit(job, "Done", err.Error()) return } dbus.Emit(job, "Stat", job.op.Result().(operations.StatProperty)) dbus.Emit(job, "Done", "") }) job.op.Execute() }
func (manager *MonitorManager) Unwatcher(id uint32) { watcherID := WatcherID(id) watcher, ok := manager.watchers[watcherID] if !ok { Log.Warning("watcher %d not found", watcherID) return } Log.Info("unwatcher", watcherID) dbus.UnInstallObject(watcher) watcher.finalize() delete(manager.watchers, watcherID) }
func (manager *MonitorManager) Unmonitor(id uint32) { monitorID := MonitorID(id) monitor, ok := manager.monitors[monitorID] if !ok { Log.Warning("monitor %d not found", monitorID) return } Log.Info("unmonitor", monitorID) dbus.UnInstallObject(monitor) monitor.finalize() delete(manager.monitors, monitorID) }
// Execute create job. func (job *CreateJob) Execute() { go func() { defer dbus.UnInstallObject(job) err := job.op.Execute() errMsg := "" if err != nil { errMsg = err.Error() } dbus.Emit(job, "Done", job.op.Result().(string), errMsg) // TODO: // job.commandRecorder // operations.FileUndoManagerInstance().RecordJob(create, job.op) }() }
func (job *RenameJob) Execute() { defer dbus.UnInstallObject(job) job.op.ListenDone(func(err error) { var errMsg = "" if err != nil { errMsg = err.Error() } dbus.Emit(job, "Done", errMsg) }) job.op.ListenOldName(func(oldName string) { dbus.Emit(job, "OldName", oldName) }) job.op.ListenNewFile(func(fileURL string) { dbus.Emit(job, "NewFile", fileURL) }) job.op.Execute() }
func (job *DeleteJob) listenSignals() { job.op.ListenTotalAmount(func(amount int64, unit operations.AmountUnit) { dbus.Emit(job, "TotalAmount", amount, uint16(unit)) }) job.op.ListenProcessedAmount(func(size int64, unit operations.AmountUnit) { dbus.Emit(job, "ProcessedAmount", size, uint16(unit)) }) job.op.ListenPercent(func(percent int64) { dbus.Emit(job, "ProcessedPercent", percent) }) job.op.ListenDeleting(func(deletingURL string) { dbus.Emit(job, "Deleting", deletingURL) }) job.op.ListenAborted(func() { defer dbus.UnInstallObject(job) dbus.Emit(job, "Aborted") }) }
func (job *EmptyTrashJob) executeJob() { defer dbus.UnInstallObject(job) job.op.Execute() dbus.Emit(job, "Done") }
func (job *GetTemplateJob) Execute() []string { defer dbus.UnInstallObject(job) return job.op.Execute() }
// Abort the job. func (job *ListJob) Abort() { job.op.Abort() dbus.Emit(job, "Aborted") dbus.UnInstallObject(job) }