示例#1
0
 private void InitializeTransfers()
 {
     _controller.Background(delegate
     {
         var transfers = TransferCollection.defaultCollection();
         lock (transfers)
         {
             transfers.load();
         }
         transfersSemaphore.Signal();
     }, delegate { });
     if (PreferencesFactory.get().getBoolean("queue.window.open.default"))
     {
         _bc.Invoke(() =>
         {
             transfersSemaphore.Wait();
             TransferController.Instance.View.Show();
         });
     }
 }
示例#2
0
 public override void cleanup()
 {
     if (_transfer.isComplete() && !_transfer.isCanceled())
     {
         if (_transfer.isReset())
         {
             if (Preferences.instance().getBoolean("queue.removeItemWhenComplete"))
             {
                 TransferCollection.defaultCollection().remove(_transfer);
             }
             if (Preferences.instance().getBoolean("queue.orderBackOnStop"))
             {
                 if (!(TransferCollection.defaultCollection().numberOfRunningTransfers() > 0))
                 {
                     _controller.View.Close();
                 }
             }
         }
     }
     TransferCollection.defaultCollection().save();
 }
示例#3
0
            public VisitStatus VisitCollectionProperty <TSrcProperty, TSrcContainer, TSrcValue>(
                TSrcProperty srcProperty,
                ref TSrcContainer srcContainer,
                ref ChangeTracker changeTracker)
                where TSrcProperty : ICollectionProperty <TSrcContainer, TSrcValue>
            {
                var action = new TransferCollection <TSrcProperty, TSrcContainer, TSrcValue>
                {
                    Result       = m_Result,
                    SrcProperty  = srcProperty,
                    SrcContainer = srcContainer,
                    SrcValue     = srcProperty.GetValue(ref srcContainer)
                };

                var sourcePropertyName = srcProperty.GetName();

                if (m_DstPropertyBag.FindProperty(
                        sourcePropertyName,
                        ref m_DstContainer,
                        ref changeTracker,
                        ref action))
                {
                    return(VisitStatus.Handled);
                }

                var visitor = new FormerlySerializedAsVisitor(sourcePropertyName);

                Visit(ref m_DstContainer, ref visitor);
                if (!string.IsNullOrEmpty(visitor.CurrentName))
                {
                    m_DstPropertyBag.FindProperty(
                        visitor.CurrentName,
                        ref m_DstContainer,
                        ref changeTracker,
                        ref action);
                }

                return(VisitStatus.Handled);
            }
示例#4
0
        public static TransferCollection GetTransferCollection()
        {
            TransferCollection result = new TransferCollection();

            YellowstonePathology.Business.Mongo.Server server = new Business.Mongo.TestServer(Business.Mongo.TestServer.SQLTransferDatabasename);
            MongoCollection collection = server.Database.GetCollection<BsonDocument>("Transfer");
            MongoCursor cursor = collection.FindAllAs(typeof(BsonDocument)).SetSortOrder(SortBy.Ascending("TableName"));

            foreach (BsonDocument bsonDocument in cursor)
            {
                Transfer transfer = new Transfer();
                YellowstonePathology.Business.Mongo.BSONPropertyWriter.Write(bsonDocument, transfer);
                result.Add(transfer);
            }

            return result;
        }
示例#5
0
 public void Visit(TransferCollection transfers)
 {
 }
示例#6
0
        /// <summary>
        /// A normal (non-single-instance) application raises the Startup event every time it starts.
        /// A single-instance application raises the Startup  event when it starts only if the application
        /// is not already active; otherwise, it raises the StartupNextInstance  event.
        /// </summary>
        /// <see cref="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.applicationservices.windowsformsapplicationbase.startup.aspx"/>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ApplicationDidFinishLaunching(object sender, StartupEventArgs e)
        {
            Logger.debug("ApplicationDidFinishLaunching");

            /* UWP Registration, initialize as soon as possible */
            if (Utils.IsRunningAsUWP)
            {
                InitStoreContext();
            }

            _controller.Background(delegate
            {
                var transfers = TransferCollection.defaultCollection();
                lock (transfers)
                {
                    transfers.load();
                }
                transfersSemaphore.Signal();
            }, delegate { });
            _controller.Background(delegate { HistoryCollection.defaultCollection().load(); }, delegate { });
            CommandsAfterLaunch(CommandLineArgs);
            HistoryCollection.defaultCollection().addListener(this);
            if (PreferencesFactory.get().getBoolean("browser.serialize"))
            {
                _controller.Background(delegate { _sessions.load(); }, delegate
                {
                    foreach (Host host in _sessions)
                    {
                        Host h = host;
                        _bc.Invoke(delegate
                        {
                            BrowserController bc = NewBrowser();
                            bc.Mount(h);
                        });
                    }
                    _sessions.clear();
                });
            }
            NotificationServiceFactory.get().setup();

            // User bookmarks and thirdparty applications
            CountdownEvent bookmarksSemaphore  = new CountdownEvent(1);
            CountdownEvent thirdpartySemaphore = new CountdownEvent(1);

            // Load all bookmarks in background
            _controller.Background(delegate
            {
                BookmarkCollection c = BookmarkCollection.defaultCollection();
                c.load();
                bookmarksSemaphore.Signal();
            }, delegate
            {
                if (PreferencesFactory.get().getBoolean("browser.open.untitled"))
                {
                    if (PreferencesFactory.get().getProperty("browser.open.bookmark.default") != null)
                    {
                        _bc.Invoke(delegate
                        {
                            BrowserController bc = NewBrowser();
                            OpenDefaultBookmark(bc);
                        });
                    }
                }
            });
            if (PreferencesFactory.get().getBoolean("queue.window.open.default"))
            {
                _bc.Invoke(delegate
                {
                    transfersSemaphore.Wait();
                    TransferController.Instance.View.Show();
                });
            }
            // Bonjour initialization
            ThreadStart start = delegate
            {
                try
                {
                    RendezvousFactory.instance().init();
                }
                catch (COMException)
                {
                    Logger.warn("No Bonjour support available");
                }
            };
            Thread thread = new Thread(start);

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            if (PreferencesFactory.get().getBoolean("defaulthandler.reminder") &&
                PreferencesFactory.get().getInteger("uses") > 0)
            {
                var handler = SchemeHandlerFactory.get();
                if (
                    !handler.isDefaultHandler(Arrays.asList(Scheme.ftp, Scheme.ftps, Scheme.sftp),
                                              new Application(System.Windows.Forms.Application.ExecutablePath)))
                {
                    Core.Utils.CommandBox(LocaleFactory.localizedString("Default Protocol Handler", "Preferences"),
                                          LocaleFactory.localizedString(
                                              "Set Cyberduck as default application for FTP and SFTP locations?", "Configuration"),
                                          LocaleFactory.localizedString(
                                              "As the default application, Cyberduck will open when you click on FTP or SFTP links in other applications, such as your web browser. You can change this setting in the Preferences later.",
                                              "Configuration"),
                                          String.Format("{0}|{1}", LocaleFactory.localizedString("Change", "Configuration"),
                                                        LocaleFactory.localizedString("Cancel", "Configuration")), false,
                                          LocaleFactory.localizedString("Don't ask again", "Configuration"), TaskDialogIcon.Question,
                                          delegate(int option, bool verificationChecked)
                    {
                        if (verificationChecked)
                        {
                            // Never show again.
                            PreferencesFactory.get().setProperty("defaulthandler.reminder", false);
                        }
                        switch (option)
                        {
                        case 0:
                            handler.setDefaultHandler(Arrays.asList(Scheme.ftp, Scheme.ftps, Scheme.sftp),
                                                      new Application(System.Windows.Forms.Application.ExecutablePath));
                            break;
                        }
                    });
                }
            }
            // Import thirdparty bookmarks.
            IList <ThirdpartyBookmarkCollection> thirdpartyBookmarks = GetThirdpartyBookmarks();

            _controller.Background(delegate
            {
                foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks)
                {
                    if (!c.isInstalled())
                    {
                        Logger.info("No application installed for " + c.getBundleIdentifier());
                        continue;
                    }
                    c.load();
                    if (c.isEmpty())
                    {
                        if (!PreferencesFactory.get().getBoolean(c.getConfiguration()))
                        {
                            // Flag as imported
                            PreferencesFactory.get().setProperty(c.getConfiguration(), true);
                        }
                    }
                }
                bookmarksSemaphore.Wait();
            }, delegate
            {
                foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks)
                {
                    BookmarkCollection bookmarks = BookmarkCollection.defaultCollection();
                    c.filter(bookmarks);
                    if (!c.isEmpty())
                    {
                        ThirdpartyBookmarkCollection c1 = c;
                        Core.Utils.CommandBox(LocaleFactory.localizedString("Import", "Configuration"),
                                              String.Format(LocaleFactory.localizedString("Import {0} Bookmarks", "Configuration"),
                                                            c.getName()),
                                              String.Format(
                                                  LocaleFactory.localizedString(
                                                      "{0} bookmarks found. Do you want to add these to your bookmarks?", "Configuration"),
                                                  c.size()),
                                              String.Format("{0}", LocaleFactory.localizedString("Import", "Configuration")), true,
                                              LocaleFactory.localizedString("Don't ask again", "Configuration"), TaskDialogIcon.Question,
                                              delegate(int option, bool verificationChecked)
                        {
                            if (verificationChecked)
                            {
                                // Flag as imported
                                PreferencesFactory.get().setProperty(c1.getConfiguration(), true);
                            }
                            switch (option)
                            {
                            case 0:
                                BookmarkCollection.defaultCollection().addAll(c1);
                                // Flag as imported
                                PreferencesFactory.get().setProperty(c1.getConfiguration(), true);
                                break;
                            }
                        });
                    }
                    else
                    {
                        PreferencesFactory.get().setProperty(c.getConfiguration(), true);
                    }
                }
                thirdpartySemaphore.Signal();
            });
            // register callbacks
            _canShutdownCallback     = CanShutdownCallback;
            _shutdownRequestCallback = ShutdownRequestCallback;
            WinSparklePeriodicUpdateChecker.SetCanShutdownCallback(_canShutdownCallback);
            WinSparklePeriodicUpdateChecker.SetShutdownRequestCallback(_shutdownRequestCallback);
            if (PreferencesFactory.get().getBoolean("update.check"))
            {
                _updater = PeriodicUpdateCheckerFactory.get();
                if (_updater.hasUpdatePrivileges())
                {
                    DateTime lastCheck = new DateTime(PreferencesFactory.get().getLong("update.check.last"));
                    TimeSpan span      = DateTime.Now.Subtract(lastCheck);
                    _updater.register();
                    if (span.TotalSeconds >= PreferencesFactory.get().getLong("update.check.interval"))
                    {
                        _updater.check(true);
                    }
                }
            }
        }
示例#7
0
        /// <summary>
        /// A normal (non-single-instance) application raises the Startup event every time it starts.
        /// A single-instance application raises the Startup  event when it starts only if the application
        /// is not already active; otherwise, it raises the StartupNextInstance  event.
        /// </summary>
        /// <see cref="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.applicationservices.windowsformsapplicationbase.startup.aspx"/>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ApplicationDidFinishLaunching(object sender, StartupEventArgs e)
        {
            Logger.debug("ApplicationDidFinishLaunching");
            CommandsAfterLaunch(CommandLineArgs);

            UpdateController.Instance.CheckForUpdatesIfNecessary();

            if (Preferences.instance().getBoolean("queue.openByDefault"))
            {
                TransferController.Instance.View.Show();
            }

            if (Preferences.instance().getBoolean("browser.serialize"))
            {
                _bc.Background(delegate { _sessions.load(); },
                               delegate
                {
                    foreach (
                        Host host in
                        _sessions)
                    {
                        NewBrowser().Mount(host);
                    }
                    _sessions.clear();
                });
            }
            //Registering for Growl is an expensive operation. Takes up to 500ms on my machine.
            _bc.Background(delegate { ch.cyberduck.ui.growl.Growl.instance().register(); }, delegate { });

            // User bookmarks and thirdparty applications
            CountdownEvent cde = new CountdownEvent(2);

            _bc.Background(delegate
            {
                BookmarkCollection c = BookmarkCollection.defaultCollection();
                c.load();
                cde.Signal();
            }, delegate
            {
                if (Preferences.instance
                        ().getBoolean(
                        "browser.openUntitled"))
                {
                    if (
                        Browsers.Count ==
                        0)
                    {
                        OpenDefaultBookmark
                            (NewBrowser());
                    }
                }
            });
            _bc.Background(delegate { HistoryCollection.defaultCollection().load(); }, delegate { });
            _bc.Background(delegate { TransferCollection.defaultCollection().load(); }, delegate { });

            // Bonjour initialization);
            if (Preferences.instance().getBoolean("rendezvous.enable"))
            {
                try
                {
                    RendezvousFactory.instance().init();
                }
                catch (COMException)
                {
                    Logger.warn("No Bonjour support available");
                }
            }
            if (Preferences.instance().getBoolean("defaulthandler.reminder") &&
                Preferences.instance().getInteger("uses") > 0)
            {
                if (!URLSchemeHandlerConfiguration.Instance.IsDefaultApplicationForFtp() ||
                    !URLSchemeHandlerConfiguration.Instance.IsDefaultApplicationForSftp())
                {
                    _bc.CommandBox(
                        Locale.localizedString("Default Protocol Handler", "Preferences"),
                        Locale.localizedString("Set Cyberduck as default application for FTP and SFTP locations?",
                                               "Configuration"),
                        Locale.localizedString(
                            "As the default application, Cyberduck will open when you click on FTP or SFTP links in other applications, such as your web browser. You can change this setting in the Preferences later.",
                            "Configuration"),
                        String.Format("{0}|{1}",
                                      Locale.localizedString("Change", "Configuration"),
                                      Locale.localizedString("Cancel", "Configuration")),
                        false, Locale.localizedString("Don't ask again", "Configuration"), SysIcons.Question,
                        delegate(int option, bool verificationChecked)
                    {
                        if (verificationChecked)
                        {
                            // Never show again.
                            Preferences.instance().setProperty(
                                "defaulthandler.reminder", false);
                        }
                        switch (option)
                        {
                        case 0:
                            URLSchemeHandlerConfiguration.Instance.
                            RegisterFtpProtocol();
                            URLSchemeHandlerConfiguration.Instance.
                            RegisterSftpProtocol();
                            break;
                        }
                    });
                }
            }
            // Import thirdparty bookmarks.
            IList <ThirdpartyBookmarkCollection> thirdpartyBookmarks = GetThirdpartyBookmarks();

            _bc.Background(delegate
            {
                foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks)
                {
                    if (!Preferences.instance().getBoolean(c.getConfiguration()))
                    {
                        if (!c.isInstalled())
                        {
                            Logger.info("No application installed for " + c.getBundleIdentifier());
                            continue;
                        }
                        c.load();
                        if (c.isEmpty())
                        {
                            // Flag as imported
                            Preferences.instance().setProperty(c.getConfiguration(), true);
                        }
                    }
                }
            },
                           delegate
            {
                foreach (ThirdpartyBookmarkCollection c in thirdpartyBookmarks)
                {
                    if (!Preferences.instance().getBoolean(c.getConfiguration()))
                    {
                        if (!c.isEmpty())
                        {
                            ThirdpartyBookmarkCollection c1 = c;
                            _bc.CommandBox(Locale.localizedString("Import", "Configuration"),
                                           String.Format(
                                               Locale.localizedString("Import {0} Bookmarks",
                                                                      "Configuration"), c.getName()),
                                           String.Format(
                                               Locale.localizedString(
                                                   "{0} bookmarks found. Do you want to add these to your bookmarks?",
                                                   "Configuration"), c.size()),
                                           String.Format("{0}",
                                                         Locale.localizedString("Import",
                                                                                "Configuration")),
                                           true,
                                           Locale.localizedString("Don't ask again", "Configuration"),
                                           SysIcons.Question,
                                           delegate(int option, bool verificationChecked)
                            {
                                if (verificationChecked)
                                {
                                    // Flag as imported
                                    Preferences.instance().setProperty(
                                        c1.getConfiguration(), true);
                                }
                                switch (option)
                                {
                                case 0:
                                    BookmarkCollection.defaultCollection().
                                    addAll(c1);
                                    // Flag as imported
                                    Preferences.instance().setProperty(
                                        c1.getConfiguration(), true);
                                    break;
                                }
                            });
                        }
                    }
                }
                cde.Signal();
            });


            _bc.Background(delegate
            {
                cde.Wait();
                BookmarkCollection c = BookmarkCollection.defaultCollection();
                if (c.isEmpty())
                {
                    FolderBookmarkCollection defaults =
                        new FolderBookmarkCollection(LocalFactory.createLocal(
                                                         Preferences.instance().getProperty("application.bookmarks.path")
                                                         ));
                    defaults.load();
                    foreach (Host bookmark in defaults)
                    {
                        if (Logger.isDebugEnabled())
                        {
                            Logger.debug("Adding default bookmark:" + bookmark);
                        }
                        c.add(bookmark);
                    }
                }
            }, delegate { });
        }
示例#8
0
 protected virtual void OnTransfersChecked(TransferCollection transfers, ValidationEventArgs e)
 {
     TransfersChecked?.Invoke(transfers, e);
 }
示例#9
0
 public void Visit(TransferCollection transfers)
 {
     OnTransfersChecked(transfers, new ValidationEventArgs(CheckValidity(transfers)));
 }