Esempio n. 1
0
        public SparkleFetcherBase(SparkleFetcherInfo info)
        {
            OriginalFetcherInfo = info;
            RequiredFingerprint = info.Fingerprint;
            FetchPriorHistory   = info.FetchPriorHistory;
            string remote_path = info.RemotePath.Trim("/".ToCharArray());
            string address     = info.Address;

            if (address.EndsWith("/"))
            {
                address = address.Substring(0, address.Length - 1);
            }

            if (!remote_path.StartsWith("/"))
            {
                remote_path = "/" + remote_path;
            }

            if (!address.Contains("://"))
            {
                address = "ssh://" + address;
            }

            TargetFolder = info.TargetDirectory;

            RemoteUrl = new Uri(address + remote_path);
            IsActive  = false;
        }
        public SparkleFetcher(SparkleFetcherInfo info)
            : base(info)
        {
            if (RemoteUrl.ToString ().StartsWith ("ssh+"))
                RemoteUrl = new Uri ("ssh" + RemoteUrl.ToString ().Substring (RemoteUrl.ToString ().IndexOf ("://")));

            Uri uri = RemoteUrl;

            if (!uri.Scheme.Equals ("ssh") && !uri.Scheme.Equals ("https") &&
                !uri.Scheme.Equals ("http") && !uri.Scheme.Equals ("git")) {

                uri = new Uri ("ssh://" + uri);
            }

            if (uri.Host.Equals ("gitorious.org") && !uri.Scheme.StartsWith ("http")) {
                if (!uri.AbsolutePath.Equals ("/") &&
                    !uri.AbsolutePath.EndsWith (".git")) {

                    uri = new Uri ("ssh://[email protected]" + uri.AbsolutePath + ".git");

                } else {
                    uri = new Uri ("ssh://[email protected]" + uri.AbsolutePath);
                }

            } else if (uri.Host.Equals ("github.com") && !uri.Scheme.StartsWith ("http")) {
                uri = new Uri ("ssh://[email protected]" + uri.AbsolutePath);

            } else if (uri.Host.Equals ("bitbucket.org") && !uri.Scheme.StartsWith ("http")) {
                // Nothing really

            } else {
                if (string.IsNullOrEmpty (uri.UserInfo) && !uri.Scheme.StartsWith ("http")) {
                    if (uri.Port == -1)
                        uri = new Uri (uri.Scheme + "://storage@" + uri.Host + uri.AbsolutePath);
                    else
                        uri = new Uri (uri.Scheme + "://storage@" + uri.Host + ":" + uri.Port + uri.AbsolutePath);
                }

                this.use_git_bin = false; // TODO
            }

            RemoteUrl = uri;
        }
        public void StartFetcher (SparkleFetcherInfo info)
        {
            string tmp_path = this.config.TmpPath;

            if (!Directory.Exists (tmp_path)) {
                Directory.CreateDirectory (tmp_path);
                File.SetAttributes (tmp_path, File.GetAttributes (tmp_path) | FileAttributes.Hidden);
            }

            string canonical_name = Path.GetFileName (info.RemotePath);
            string backend        = SparkleFetcherBase.GetBackend (info.Address);
            info.TargetDirectory  = Path.Combine (tmp_path, canonical_name);

            try {
                this.fetcher = (SparkleFetcherBase) Activator.CreateInstance (
                    Type.GetType ("SparkleLib." + backend + ".SparkleFetcher, SparkleLib." + backend), info);

            } catch (Exception e) {
                SparkleLogger.LogInfo ("Controller",
                    "Failed to load '" + backend + "' backend for '" + canonical_name + "' " + e.Message);

                FolderFetchError (Path.Combine (info.Address, info.RemotePath).Replace (@"\", "/"),
                    new string [] {"Failed to load \"" + backend + "\" backend for \"" + canonical_name + "\""});

                return;
            }

            this.fetcher.Finished += delegate (bool repo_is_encrypted, bool repo_is_empty, string [] warnings) {
                if (repo_is_encrypted && repo_is_empty) {
                    ShowSetupWindowEvent (PageType.CryptoSetup);

                } else if (repo_is_encrypted) {
                    ShowSetupWindowEvent (PageType.CryptoPassword);

                } else {
                    FinishFetcher ();
                }
            };

            this.fetcher.Failed += delegate {
                FolderFetchError (this.fetcher.RemoteUrl.ToString (), this.fetcher.Errors);
                StopFetcher ();
            };
            
            this.fetcher.ProgressChanged += delegate (double percentage) {
                FolderFetching (percentage);
            };

            this.fetcher.Start ();
        }
        public SparkleFetcherBase (SparkleFetcherInfo info)
        {
            OriginalFetcherInfo = info;
            RequiredFingerprint = info.Fingerprint;
            FetchPriorHistory   = info.FetchPriorHistory;
            string remote_path  = info.RemotePath.Trim ("/".ToCharArray ());
            string address      = info.Address;

            if (address.EndsWith ("/"))
                address = address.Substring (0, address.Length - 1);

            if (!remote_path.StartsWith ("/"))
                remote_path = "/" + remote_path;

            if (!address.Contains ("://"))
                address = "ssh://" + address;

            TargetFolder = info.TargetDirectory;

            RemoteUrl = new Uri (address + remote_path);
            IsActive  = false;
        }
Esempio n. 5
0
 public SparkleFetcherSSH(SparkleFetcherInfo info)
     : base(info)
 {
 }
        public void InvitePageCompleted ()
        {
            SyncingFolder = Path.GetFileName (PendingInvite.RemotePath);

            if (PendingInvite.RemotePath.EndsWith (".git"))
                SyncingFolder = PendingInvite.RemotePath.Substring (0, PendingInvite.RemotePath.Length - 4);

			SyncingFolder   = SyncingFolder.Replace ("-crypto", "");
			SyncingFolder   = SyncingFolder.Replace ("_", " ");
            PreviousAddress = PendingInvite.Address;
            PreviousPath    = PendingInvite.RemotePath;

            ChangePageEvent (PageType.Syncing, null);

            new Thread (() => {
                if (!PendingInvite.Accept (Program.Controller.CurrentUser.PublicKey)) {
                    PreviousUrl = PendingInvite.Address + PendingInvite.RemotePath.TrimStart ("/".ToCharArray ());
                    ChangePageEvent (PageType.Error, new string [] { "error: Failed to upload the public key" });
                    return;
                }

                Program.Controller.FolderFetched    += InvitePageFetchedDelegate;
                Program.Controller.FolderFetchError += InvitePageFetchErrorDelegate;
                Program.Controller.FolderFetching   += SyncingPageFetchingDelegate;

                SparkleFetcherInfo info = new SparkleFetcherInfo {
                    Address           = PendingInvite.Address,
                    Fingerprint       = PendingInvite.Fingerprint,
                    RemotePath        = PendingInvite.RemotePath,
                    FetchPriorHistory = false, // TODO: checkbox on invite page
                    AnnouncementsUrl  = PendingInvite.AnnouncementsUrl
                };

                Program.Controller.StartFetcher (info);

            }).Start ();
        }
        public void AddPageCompleted (string address, string remote_path)
        {
            SyncingFolder = Path.GetFileName (remote_path);

            if (remote_path.EndsWith (".git"))
                SyncingFolder = remote_path.Substring (0, remote_path.Length - 4);

			SyncingFolder         = SyncingFolder.Replace ("-crypto", "");
			SyncingFolder         = SyncingFolder.Replace ("_", " ");
            ProgressBarPercentage = 1.0;

            ChangePageEvent (PageType.Syncing, null);

            address     = Uri.EscapeUriString (address.Trim ());
            remote_path = remote_path.Trim ();
            remote_path = remote_path.TrimEnd ("/".ToCharArray ());

            if (SelectedPlugin.PathUsesLowerCase)
                remote_path = remote_path.ToLower ();

            PreviousAddress = address;
            PreviousPath    = remote_path;

            Program.Controller.FolderFetched    += AddPageFetchedDelegate;
            Program.Controller.FolderFetchError += AddPageFetchErrorDelegate;
            Program.Controller.FolderFetching   += SyncingPageFetchingDelegate;

            SparkleFetcherInfo info = new SparkleFetcherInfo {
                Address           = address,
                Fingerprint       = SelectedPlugin.Fingerprint,
                RemotePath        = remote_path,
                FetchPriorHistory = this.fetch_prior_history,
                AnnouncementsUrl  = SelectedPlugin.AnnouncementsUrl,
                Backend           = SelectedPlugin.Backend 
            };

            new Thread (() => { Program.Controller.StartFetcher (info); }).Start ();
        }
Esempio n. 8
0
 public SparkleFetcherSSH(SparkleFetcherInfo info) : base(info)
 {
 }