Ejemplo n.º 1
0
        public void UpdateInfos(KfsStatusPath obj)
        {
            m_fileName = obj.Name;

            if ((obj.IsDir() && obj.HasServerDir()) ||
                (obj.IsFile() && obj.HasServerFile() && !((KfsServerFile)obj.ServerObject).HasCurrentVersion()))
            {
                // Get the creator if obj is a directory on the server or if its a new file
                // that has no current version yet.
                m_modifiedBy = m_helper.GetUserDisplayName((UInt32)obj.ServerObject.CreationUserID);
            }
            else if(obj.IsFile() && obj.HasServerFile() &&
                ((KfsServerFile)obj.ServerObject).HasCurrentVersion() &&
                (obj.Status !=  PathStatus.ModifiedCurrent && obj.Status != PathStatus.ModifiedStale))
            {
                // We have a file and its current version, and it is NOT modified locally.
                m_modifiedBy = m_helper.GetUserDisplayName(((KfsServerFile)obj.ServerObject).CurrentVersion.UserID);
            }
            else
            {
                m_modifiedBy = m_helper.GetUserDisplayName(m_helper.GetKwmUserID());
            }

            m_modifiedDate = obj.LastModifiedDate;

            m_path = obj.Path;
            m_status = obj.Status;
            m_onServer = obj.OnServer();

            m_size = obj.Size;

            m_isFile = obj.IsFile();
            m_isDirectory = obj.IsDir();

            this.Text = m_fileName;
            this.Name = m_fileName;

            // FIXME : need a way to distinguish between an upload and a download.
            // Always set the icon, play with ShowIcon to display it or not.
            // This crashes the kwm with a Corrupted memory exception. See if the ressource is ok.
            /*((CustomListViewSubItem)SubItems[TransferStatusKey]).icon = KwmAppControls.Properties.Resources.download;
            if (obj.Share.IsTransferringFile(m_path))
                ((CustomListViewSubItem)SubItems[TransferStatusKey]).showIcon = true;
            else
                ((CustomListViewSubItem)SubItems[TransferStatusKey]).showIcon = true;
             * */

            SubItems[ModifiedDateKey].Text = m_modifiedDate.ToString();
            SubItems[ModifiedByKey].Text = m_modifiedBy;

            if (m_size != UInt64.MaxValue)
                SubItems[SizeKey].Text = Base.GetHumanFileSize(m_size);
            else if (m_status == PathStatus.Directory)
                SubItems[SizeKey].Text = "";
            else
                SubItems[SizeKey].Text = "In progress...";

            if (m_status == PathStatus.Directory)
            {
                if (obj.OnServer())
                    SubItems[StatusKey].Text = "";
                else
                    SubItems[StatusKey].Text = "Not Added";
            }
            else
            {
                SubItems[StatusKey].Text = Base.GetEnumDescription(m_status);
                m_hasCurrentVersion = (obj.HasServerFile() && ((KfsServerFile)obj.ServerObject).HasCurrentVersion());
            }

            Font strikeout = new Font(this.Font, FontStyle.Strikeout);
            Font standard = new Font(this.Font, FontStyle.Regular);
            Font italic = new Font(this.Font, FontStyle.Italic);

            // Set default color and style
            this.Font = standard;
            this.ForeColor = Color.Black;

            // Modify color / style for specific statuses.
            switch (m_status)
            {
                case PathStatus.NotAdded:
                    this.Font = italic;
                    break;
                case PathStatus.Directory:
                    if (!m_onServer)
                        this.Font = italic;
                    break;
                case PathStatus.DirFileConflict:
                case PathStatus.FileDirConflict:
                case PathStatus.ModifiedStale:
                    this.ForeColor = Color.Red;
                    break;
                case PathStatus.NotDownloaded:
                    this.ForeColor = Color.DarkGray;
                    break;
            }
        }
Ejemplo n.º 2
0
Archivo: KfsGate.cs Proyecto: tmbx/kwm
        /// <summary>
        /// Helper method for SynchronizePath().
        /// </summary>
        private void SynchronizePathRecursive(KfsStatusPath sp, bool openWhenDownloaded, bool canUpload)
        {
            if (openWhenDownloaded)
                Debug.Assert(sp.Status == PathStatus.NotDownloaded ||
                             sp.Status == PathStatus.UnmodifiedStale);

            // Synchronize file.
            if (sp.Status == PathStatus.NotDownloaded ||
                (sp.Status == PathStatus.ModifiedCurrent && canUpload) ||
                sp.Status == PathStatus.UnmodifiedStale)
            {
                KfsServerFile f = sp.ServerObject as KfsServerFile;
                Debug.Assert(f != null);

                if (Share.IsTransferringFile(sp.Path)) return;

                // Queue download.
                if ((sp.Status == PathStatus.NotDownloaded && sp.ServerObject.HasCurrentVersion()) ||
                    sp.Status == PathStatus.UnmodifiedStale)
                {
                    Share.DownloadManager.QueueDownload(f.CurrentVersion, openWhenDownloaded);
                }

                // Queue upload.
                else if (sp.Status == PathStatus.ModifiedCurrent)
                {
                    Share.UploadManager.QueueUpload(sp.Path);
                }
                else
                {
                    // Not synchronizable.
                }
            }

            // Synchronize directory.
            else if (sp.HasServerDir())
            {
                // Create the directory locally if needed.
                Share.AddMissingLocalDirectories(sp.Path);

                // Synchronize the children.
                foreach (KfsStatusPath child in sp.ChildTree.Values)
                    SynchronizePathRecursive(child, openWhenDownloaded, canUpload);
            }
        }