Example #1
0
        public KListViewItem(KfsStatusPath obj, IAppHelper _helper)
        {
            /* Create all subitems, without any text in them */
            CustomListViewSubItem subItem;
            m_helper = _helper;

            subItem = new CustomListViewSubItem();
            subItem.Name = SizeKey;
            AddCustomSubItem(subItem);

            subItem = new CustomListViewSubItem();
            subItem.Name = TransferStatusKey;
            AddCustomSubItem(subItem);

            subItem = new CustomListViewSubItem();
            subItem.Name = ModifiedDateKey;
            AddCustomSubItem(subItem);

            subItem = new CustomListViewSubItem();
            subItem.Name = ModifiedByKey;
            AddCustomSubItem(subItem);

            subItem = new CustomListViewSubItem();
            subItem.Name = StatusKey;
            AddCustomSubItem(subItem);

            subItem = new CustomListViewSubItem();
            subItem.Name = CommitIDKey;
            AddCustomSubItem(subItem);

            UpdateInfos(obj);
        }
Example #2
0
        public KTreeNode(KfsStatusPath obj, ImageListManager mgr, IAppHelper _helper)
            : base()
        {
            Debug.Assert(obj.IsDir());
            m_helper = _helper;

            m_childs = new SortedDictionary<string, KListViewItem>();
            m_onServer = obj.OnServer();

            m_lvImageListMgr = mgr;

            this.Text = obj.IsRoot() ? "Share" : obj.Name;
            this.ImageKey = "FolderClosed";
            this.SelectedImageKey = "FolderOpened";
            m_status = obj.Status;
            m_name = obj.Name;

            CreateChilds(obj);
        }
Example #3
0
        private void UpdateTV(KfsStatusPath path, KTreeNode node)
        {
            KTreeNode self = new KTreeNode(path, m_lvImageListMgr, SrcApp.Helper);
            self.Name = path.Path;

            node.Nodes.Add(self);

            foreach (KfsStatusPath p in path.ChildTree.Values)
            {
                if (p.Status == PathStatus.Directory)
                    UpdateTV(p, self);
            }

            KfsLocalDirectory localDir = SrcApp.Share.LocalView.GetObjectByPath(path.Path) as KfsLocalDirectory;
            KfsServerDirectory serverDir = SrcApp.Share.ServerView.GetObjectByPath(path.Path) as KfsServerDirectory;
            if (localDir != null && localDir.ExpandedFlag ||
                serverDir != null && serverDir.ExpandedFlag)
            {
                self.Expand();
            }
        }
Example #4
0
 /// <summary>
 /// Helper method for GetPathArray().
 /// </summary>
 private void GetPathArrayRecursive(List<KfsStatusPath> a, KfsStatusPath c, bool lf)
 {
     if (!lf) a.Add(c);
     foreach (KfsStatusPath s in c.ChildTree.Values) GetPathArrayRecursive(a, s, lf);
     if (lf) a.Add(c);
 }
Example #5
0
        /// <summary>
        /// Update the status view from the current server and local views.
        /// </summary>
        public void UpdateView()
        {
            // There are no type conflicts at this point.
            Share.TypeConflictFlag = false;
            Clear();

            List<String> localPathArray = Share.LocalView.GetPathArray(false);
            List<String> serverPathArray = Share.ServerView.GetPathArray(false);

            // Find the entries that are present in both the local view and in the
            // server view.
            foreach (String path in localPathArray)
            {
                KfsLocalObject lo = Share.LocalView.GetObjectByPath(path);
                KfsServerObject so = Share.ServerView.GetObjectByPath(path);
                Debug.Assert(lo != null);
                KfsStatusPath sp = new KfsStatusPath(Share, path, lo, so);
                sp.AddToView();
            }

            // Find the entries that are present only in the server view.
            foreach (String path in serverPathArray)
            {
                if (GetPath(path) != null) continue;
                KfsServerObject so = Share.ServerView.GetObjectByPath(path);
                Debug.Assert(so != null);
                KfsStatusPath sp = new KfsStatusPath(Share, path, null, so);
                sp.AddToView();
            }

            // Link the entries properly, compute their status and remember conflicts.
            Debug.Assert(Root != null);

            foreach (KfsStatusPath sp in PathTree.Values)
            {
                sp.UpdateStatus();
                if (sp.Status == PathStatus.DirFileConflict || sp.Status == PathStatus.FileDirConflict)
                    Share.TypeConflictFlag = true;
            }

            // If there are type conflicts, disallow all user operations but downloads.
            if (Share.TypeConflictFlag)
                Share.DisallowUserOp("type conflicts detected", AllowedOpStatus.Download);
        }
Example #6
0
 /// <summary>
 /// Clear the content of the status view.
 /// </summary>
 public void Clear()
 {
     Root = null;
     PathTree.Clear();
 }
Example #7
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;
            }
        }
Example #8
0
File: KfsGate.cs Project: 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);
            }
        }
Example #9
0
File: KfsGate.cs Project: tmbx/kwm
 /// <summary>
 /// Helper method for ResolveTypeConflicts.
 /// </summary>
 /// <param name="sp"></param>
 /// <returns>True to cancel the operation.</returns>
 private void ResolveTypeConflictRecursive(KfsStatusPath sp)
 {
     Debug.Assert(sp.IsDir());
     foreach (KfsStatusPath s in sp.ChildTree.Values)
     {
         if (s.IsDir())
         {
             ResolveTypeConflictRecursive(s);
         }
         else if (s.IsTypeConflict())
         {
             DoResolveTypeConflict(s);
         }
         // else: no problem, keep going.
     }
 }
Example #10
0
File: KfsGate.cs Project: tmbx/kwm
        /// <summary>
        /// Interact with the user in order to resolve the type conflict in question.
        /// </summary>
        /// <param name="sp"></param>
        private void DoResolveTypeConflict(KfsStatusPath sp)
        {
            Debug.Assert(sp.IsTypeConflict());
            string startLocation = "";
            if (sp.Parent == null)
                startLocation = Share.MakeAbsolute("");
            else
                startLocation = Share.MakeAbsolute(sp.Parent.Path);

            bool delete = true;
            string newName = "";
            while (true)
            {
                FrmResolveTypeConflict frm = new FrmResolveTypeConflict(startLocation);
                string local = (sp.Status == PathStatus.DirFileConflict ? "directory" : "file");
                string remote = (sp.Status == PathStatus.DirFileConflict ? "file" : "directory");

                string msg = "Your local {0} \"{1}\" conflicts with a remote {2} that has the same name. You can either delete your local {0}, or rename it to something else.";

                frm.radioDelete.Checked = delete;
                frm.radioRename.Checked = !delete;
                frm.txtNewName.Text = newName;

                frm.lblText.Text = string.Format(msg, local, sp.Path, remote);
                frm.radioDelete.Text = "Delete \"" + sp.Name + "\"";
                frm.radioRename.Text = "Rename \"" + sp.Name + "\" to ...";
                Misc.OnUiEntry();
                DialogResult r = frm.ShowDialog();
                Misc.OnUiExit();

                if (r != DialogResult.OK)
                    throw new GateCancelledException();

                delete = frm.Delete;
                newName = frm.txtNewName.Text;

                string itmPath = Share.MakeAbsolute(sp.Path);

                if (File.Exists(itmPath) || Directory.Exists(itmPath))
                    File.SetAttributes(itmPath, FileAttributes.Normal);

                if (frm.Delete)
                {
                    try
                    {
                        // Perform local deletion.
                        if (File.Exists(itmPath))
                        {
                            File.Delete(itmPath);
                        }
                        else if (Directory.Exists(itmPath))
                        {
                            Directory.Delete(itmPath, true);
                        }
                    }
                    catch (Exception ex)
                    {
                        Misc.KwmTellUser("Unable to perform deletion : " + ex.Message);
                        continue;
                    }
                }
                else
                {
                    // Perform local rename.
                    try
                    {
                        File.Move(itmPath, KfsPath.DirName(itmPath) + frm.txtNewName.Text);
                    }
                    catch (Exception ex)
                    {
                        Misc.KwmTellUser("Unable to perform rename : " + ex.Message);
                        continue;
                    }
                }
                return;
            }
        }
Example #11
0
        /// <summary>
        /// Populates the objects contained in this directory.
        /// </summary>
        /// <param name="obj"></param>
        private void CreateChilds(KfsStatusPath obj)
        {
            foreach (KeyValuePair<string, KfsStatusPath> content in obj.ChildTree)
            {
                KfsStatusPath val = content.Value as KfsStatusPath;
                Debug.Assert(val != null);

                KListViewItem newItem = new KListViewItem(val, m_helper);
                if (val.Status == PathStatus.Directory)
                    newItem.ImageKey = "FolderClosed";
                else if (val.HasLocalFile() && NeedsIconCheck(newItem.FileName))
                    newItem.ImageKey = m_lvImageListMgr.GetImageKey(val.Share.MakeAbsolute(val.Path));
                else
                    newItem.ImageKey = m_lvImageListMgr.GetImageKey(Path.GetExtension(newItem.FileName));

                newItem.Name = val.Name;

                m_childs.Add(val.Name, newItem);
            }
        }