Beispiel #1
0
 public SharePanelItem(PanelItemBase parent, string name) : base(parent)
 {
     m_SHI = new ShareInfo(new SHARE_INFO_1 {
         netname = name
     });
     Comment = string.Empty;
 }
Beispiel #2
0
        public static IComparable GetReachable(PanelItemBase item)
        {
            var    ipAddr = InternalGetIPAddress(item.Name);
            string result = string.Empty;

            using (var ping = new Ping())
            {
                var pingReply = ping.Send(ipAddr);
                if (pingReply == null)
                {
                    item.IsReachable = false;
                }
                else if (pingReply.Status == IPStatus.Success)
                {
                    result           = pingReply.RoundtripTime == 0 ? Resources.OK : string.Format(Resources.OK_ms, pingReply.RoundtripTime);
                    item.IsReachable = true;
                }
                else
                {
                    result = pingReply.Status.ToString();
                    if (result.StartsWith("Destination"))
                    {
                        result = result.Substring("Destination".Length);
                    }
                    item.IsReachable = false;
                }
            }
            return(result);
        }
Beispiel #3
0
        public PanelFillerResult RetrievePanelItems(PanelItemBase parent, RetrieveMode mode)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }
            var result = new PanelFillerResult();

            foreach (var pair in m_Fillers)
            {
                if (pair.Value.IsParentAccepted(parent))
                {
                    if (result.ItemsType == null)
                    {
                        result.ItemsType = pair.Key;
                    }
                    try
                    {
                        if (mode == RetrieveMode.Sync)
                        {
                            pair.Value.SyncFill(parent, result.Items);
                        }
                        else
                        {
                            pair.Value.AsyncFill(parent, result.Items);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.Print(ex.Message);
                    }
                }
            }
            return(result);
        }
Beispiel #4
0
 private void DoDataReady(PanelItemBase item)
 {
     if (DataReady != null)
     {
         DataReady(this, new DataReadyArgs(item));
     }
 }
Beispiel #5
0
        private void FillUsersWithSameGroup(ref PanelItemBase parent, ref ICollection <PanelItemBase> result, string startPath, string group)
        {
            using (var searcher = new DirectorySearcher())
            {
                searcher.SearchRoot = new DirectoryEntry(startPath);
                searcher.PageSize   = Int32.MaxValue;
                searcher.Filter     = "(objectCategory=person)";
                SetupPropertiesToLoad(searcher);
                searcher.PropertiesToLoad.Add(Constants.MEMBER_OF);
                try
                {
                    var results = searcher.FindAll();
                    foreach (SearchResult row in results)
                    {
                        // skip disabled users
                        var userAccControl = int.Parse(LdapUtils.SearchResult_GetString(row, Constants.ACCOUNT_CONTROL));
                        if ((userAccControl & 2) != 0)
                        {
                            continue;
                        }

                        var list = row.Properties[Constants.MEMBER_OF];
                        if (list.Contains(group))
                        {
                            result.Add(BuildUserFromSearchResult(parent, row));
                        }
                    }
                    results.Dispose();
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message);
                }
            }
        }
Beispiel #6
0
        public void SetupMenuForPanelItem(object popTop, PanelItemBase panelItem)
        {
            var subMenu = SubMenuAdapter.CreateFrom(popTop);

            if (subMenu == null)
            {
                return;
            }

            foreach (var menuItem in subMenu.Items)
            {
                var menuItem1 = menuItem as ToolStripMenuItem;
                if (menuItem1 == null)
                {
                    continue;
                }

                var addonMenuItem = menuItem1.Tag as AddonMenuItem;
                if (addonMenuItem == null)
                {
                    continue;
                }

                menuItem1.ToolTipText = string.Join(" ", AddonCommandStarter.BuildCmdLine(panelItem, addonMenuItem));

                var item = (AddonMenuItem)menuItem1.Tag;
                if (item != null)
                {
                    item.CurrentItem = panelItem;
                }
            }
        }
Beispiel #7
0
 public void AsyncFill(PanelItemBase parent, ICollection <PanelItemBase> result)
 {
     if (parent == null)
     {
         throw new ArgumentNullException("parent");
     }
     //result.Add(new PanelItemDoubleDot(parent));
     foreach (var item in NetApiHelper.NetShareEnum(parent.Name))
     {
         var si = new ShareInfo(item);
         //if (!Settings.Settings.Instance.ShowHiddenShares && SI.IsHidden)
         //    continue;
         //if (!Settings.Settings.Instance.ShowPrinters && SI.IsPrinter)
         //    continue;
         if (!ShowHiddenShares && si.IsHidden || !ShowPrinters && si.IsPrinter)
         {
             continue;
         }
         result.Add(new SharePanelItem(parent, si));
     }
     // enum logged users
     foreach (var item in NetworkHelper.NetWorkstationUserEnumNames(parent.Name))
     {
         var si = new ShareInfo();
         si.Name      = item;
         si.ShareType = 100;
         result.Add(new SharePanelItem(parent, si));
     }
 }
Beispiel #8
0
 public void SetDefaultRoot(PanelItemBase root)
 {
     if (root.Parent != null)
     {
         SetDefaultRoot(root.Parent);
     }
     CurrentPath.Push(root);
 }
Beispiel #9
0
 public void AsyncFill(PanelItemBase parent, ICollection <PanelItemBase> result)
 {
     // get domain list via OS api
     foreach (var item in NetApiHelper.NetServerEnum(null, SV_101_TYPES.SV_TYPE_DOMAIN_ENUM))
     {
         result.Add(new DomainPanelItem(parent, ServerInfo.FromNetApi32(item)));
     }
 }
Beispiel #10
0
        public bool IsParentAccepted(PanelItemBase parent)
        {
            var folder = parent as FilePanelItem;

            return((parent is DrivePanelItem) ||
                   parent.GetType().Name.Equals(SHARE_TYPE_NAME) ||
                   (folder != null && folder.IsDirectory));
        }
Beispiel #11
0
 public bool Contains(PanelItemBase panelItem)
 {
     if (m_Data.Contains(panelItem))
     {
         return(true);
     }
     return(m_Items.Contains(panelItem));
 }
Beispiel #12
0
 /// <summary>
 /// Panel item for network shared resource.
 /// </summary>
 /// <exception cref="ArgumentNullException"></exception>
 public SharePanelItem(PanelItemBase parent, ShareInfo shi) : base(parent)
 {
     if (shi == null)
     {
         throw new ArgumentNullException("shi");
     }
     m_SHI   = shi;
     Comment = m_SHI.Comment;
 }
Beispiel #13
0
        public static string[] BuildCmdLine(PanelItemBase panelItem, AddonMenuItem menuItem)
        {
            var programFileName = menuItem.ProgramValue.ExpandedFileName;
            var programArgs     = AddonProgram.ExpandCmdLine(menuItem.ProgramArgs);

            programArgs = MacroHelper.ExpandPublicProperties(programArgs, panelItem);
            return(ProtocolHelper.IsProtocol(menuItem.ProgramRef.Id)
                ? new[] { menuItem.ProgramRef.Id + programArgs }
                : new[] { programFileName, programArgs });
        }
Beispiel #14
0
        private static bool InternalPing(PanelItemBase item)
        {
            var ipAddr = InternalGetIPAddress(item.Name);

            using (var ping = new Ping())
            {
                var pingReply = ping.Send(ipAddr);
                return(pingReply != null && pingReply.Status == IPStatus.Success);
            }
        }
Beispiel #15
0
 public void AsyncFill(PanelItemBase parent, ICollection <PanelItemBase> result)
 {
     foreach (var drive in DriveInfo.GetDrives())
     {
         var fname = drive.RootDirectory.Name;
         PluginFileSystem.RegisterImageForFileName(fname);
         var item = new DrivePanelItem(parent, fname);
         item.Info = drive;
         result.Add(item);
     }
 }
Beispiel #16
0
 public Type GetFillType(PanelItemBase parent)
 {
     foreach (var pair in m_Fillers)
     {
         if (pair.Value.IsParentAccepted(parent))
         {
             return(pair.Key);
         }
     }
     return(null);
 }
Beispiel #17
0
        public void AsyncFill(PanelItemBase parent, ICollection <PanelItemBase> result)
        {
            var startPath = LdapUtils.GetDCNameFromPath(LdapUtils.GetUserPath(PluginUsers.ScreenService.UserName), 2);
            var workspace = parent as WorkspacePanelItem;

            if (workspace != null)
            {
                FillUsersWithSameGroup(ref parent, ref result, startPath, workspace.AdsPath);
            }
            else
            {
                FillUsers(ref parent, ref result, startPath);
            }
        }
Beispiel #18
0
        public void AsyncFill(PanelItemBase parent, ICollection <PanelItemBase> result)
        {
            var path  = parent.FullName;
            var files = Directory.GetFileSystemEntries(path, "*.*");

            m_PathExt = Environment.GetEnvironmentVariable("PATHEXT") + ";";
            m_PathExt = m_PathExt.ToUpper();
            foreach (var fname in files)
            {
                var file = new FilePanelItem(parent, fname);
                result.Add(file);
                //if (!file.IsDirectory && IsExecutable(fname))
                //    PluginFileSystem.RegisterImageForFileName(fname);
            }
        }
Beispiel #19
0
        public int Compare(PanelItemBase item1, PanelItemBase item2)
        {
            int result = item1.CompareTo(item2, ColumnIndex);
            var isDots = (item1 is PanelItemDoubleDot) || (item2 is PanelItemDoubleDot);

            if (isDots || SortOrder == PanelSortOrder.Ascending)
            {
                return(result);
            }
            if (SortOrder == PanelSortOrder.Descending)
            {
                return(-result);
            }
            return(0);
        }
Beispiel #20
0
 public void AsyncFill(PanelItemBase parent, ICollection <PanelItemBase> result)
 {
     if (parent == null)
     {
         throw new ArgumentNullException("parent");
     }
     //Thread.Sleep(5000);
     //result.Add(new PanelItemDoubleDot(parent));
     // get server list via OS api
     foreach (var item in NetApiHelper.NetServerEnum(parent.Name, SV_101_TYPES.SV_TYPE_ALL))
     {
         var si = ServerInfo.FromNetApi32(item);
         si.ResetUtcUpdated();
         result.Add(new ComputerPanelItem(parent, si));
     }
 }
Beispiel #21
0
        /// <summary>
        /// Returns MAC address for specified computer "item".
        /// Sends ARP request to computer's ip address.
        /// URL: http://www.codeproject.com/KB/IP/host_info_within_network.aspx
        /// </summary>
        /// <param name="item">ComputerPanelItem object.</param>
        /// <returns>MAC-address string.</returns>
        public static IComparable GetMACAddress(PanelItemBase item)
        {
            if (PluginNetwork.IPHLPAPI == null)
            {
                return(null);
            }
            var ipAddr = InternalGetIPAddress(item.Name);
            var mac    = new byte[6];
            var len    = (uint)mac.Length;

            if (0 != PluginNetwork.IPHLPAPI.SendARP(ipAddr.GetHashCode(), 0, mac, ref len))
            {
                item.IsReachable = false;
                return(string.Empty);
            }
            return(BitConverter.ToString(mac, 0, 6));
        }
Beispiel #22
0
        public AddonCommandStarter(AddonMenuItem menuItem, PanelItemBase panelItem)
        {
            if (menuItem == null)
            {
                throw new ArgumentNullException("menuItem");
            }

            if (panelItem == null)
            {
                throw new ArgumentNullException("panelItem");
            }

            m_PanelItem = panelItem;
            m_MenuItem  = menuItem;

            var factoryManager = App.Resolve <IPanelItemFactoryManager>();

            m_Checker = factoryManager.GetAvailabilityChecker(m_PanelItem.GetType());
        }
Beispiel #23
0
        private UserPanelItem BuildUserFromSearchResult(PanelItemBase parent, SearchResult row)
        {
            var user = new UserPanelItem(parent, LdapUtils.SearchResult_GetString(row, Constants.CN));

            user.AdsPath        = LdapUtils.SearchResult_GetString(row, Constants.ADSPATH);
            user.Title          = LdapUtils.SearchResult_GetString(row, Constants.TITLE);
            user.WorkPhone      = LdapUtils.SearchResult_GetString(row, Constants.WORK_PHONE);
            user.Office         = LdapUtils.SearchResult_GetString(row, Constants.OFFICE);
            user.Department     = LdapUtils.SearchResult_GetString(row, Constants.DEPARTMENT);
            user.Email          = LdapUtils.SearchResult_GetString(row, Constants.EMAIL);
            user.Company        = LdapUtils.SearchResult_GetString(row, Constants.COMPANY);
            user.Nickname       = LdapUtils.SearchResult_GetString(row, Constants.NICKNAME);
            user.LegacyLogon    = LdapUtils.SearchResult_GetString(row, Constants.LEGACY_LOGON);
            user.Description    = LdapUtils.SearchResult_GetString(row, Constants.DESCRIPTION);
            user.UserAccControl = int.Parse(LdapUtils.SearchResult_GetString(row, Constants.ACCOUNT_CONTROL));
            user.EmployeeID     = LdapUtils.SearchResult_GetString(row, Constants.EMPLOYEE_ID);
            //user.WorkPhone = "0x" + user.UserAccControl.ToString("X");
            //user.Description = row["lockoutTime"].ToString();
            return(user);
        }
Beispiel #24
0
        public void AsyncFill(PanelItemBase parent, ICollection <PanelItemBase> result)
        {
            string startPath;

            if (parent is UserPanelItem)
            {
                startPath = (parent as UserPanelItem).AdsPath;
            }
            else
            {
                startPath = LdapUtils.GetUserPath(PluginUsers.ScreenService.UserName);
            }

            using (var searcher = new DirectorySearcher())
            {
                // execute filter query to Active Directory
                searcher.SearchRoot = new DirectoryEntry(startPath);
                searcher.PageSize   = Int32.MaxValue;
                searcher.Filter     = "(objectCategory=person)"; // lockoutTime
                searcher.PropertiesToLoad.Add(Constants.MEMBER_OF);
                try
                {
                    var row = searcher.FindOne();

                    var list = row.Properties[Constants.MEMBER_OF];
                    foreach (var value in list)
                    {
                        var valueStr = (string)value;

                        var workspace = new WorkspacePanelItem(parent, LdapUtils.GetLdapValue(valueStr));
                        workspace.AdsPath = valueStr;
                        result.Add(workspace);
                    }
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message);
                }
            }
        }
Beispiel #25
0
        public IComparable AsyncGetData(PanelColumnHeader column, PanelItemBase panelItem)
        {
            IComparable result;
            bool        found;

            lock (column)
            {
                found = column.LazyDict.TryGetValue(panelItem, out result);
            }
            if (found)
            {
                return(result);
            }
            lock (m_AsyncQueue)
            {
                if (m_AsyncQueue.Contains(panelItem))
                {
                    m_AsyncQueue.Remove(panelItem);
                }
                m_AsyncQueue.AddFirst(panelItem);
            }
            UpdateThreads(column);
            return(null);
        }
Beispiel #26
0
        private void FillUsers(ref PanelItemBase parent, ref ICollection <PanelItemBase> result, string startPath)
        {
            using (var searcher = new DirectorySearcher())
            {
                // execute filter query to Active Directory
                searcher.SearchRoot = new DirectoryEntry(startPath);
                searcher.PageSize   = Int32.MaxValue;
                searcher.Filter     = "(objectCategory=person)"; // lockoutTime
                //var filter = "(&(&(|(&(objectCategory=person)(objectSid=*)(!samAccountType:1.2.840.113556.1.4.804:=3))(&(objectCategory=person)(!objectSid=*))(&(objectCategory=group)(groupType:1.2.840.113556.1.4.804:=14)))objectCategory=user)(cn=khmau.isup_builder)))";
                //var filter = "(&(&(&(objectCategory=person)(objectClass=user)(lockoutTime:1.2.840.113556.1.4.804:=4294967295))))";
                //var filter = "(&(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=16))";
                //var filter = "((!userAccountControl:1.2.840.113556.1.4.803:=2))";
                //var filter = "(!(userAccountControl:1.2.840.113556.1.4.803:=2))";
                SetupPropertiesToLoad(searcher);
                try
                {
                    var results = searcher.FindAll();
                    foreach (SearchResult row in results)
                    {
                        // skip disabled users
                        var userAccControl = int.Parse(LdapUtils.SearchResult_GetString(row, Constants.ACCOUNT_CONTROL));
                        if ((userAccControl & 2) != 0)
                        {
                            continue;
                        }

                        result.Add(BuildUserFromSearchResult(parent, row));
                    }
                    results.Dispose();
                }
                catch (Exception ex)
                {
                    Debug.Print(ex.Message);
                }
            }
        }
Beispiel #27
0
 public void AsyncFill(PanelItemBase parent, ICollection <PanelItemBase> result)
 {
     result.Add(new ShortcutPanelItem(parent, Resources.KeyF1, Resources.KeyF1__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyF10, Resources.KeyF10__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyCtrlW, Resources.KeyCtrlW__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyCtrlR, Resources.KeyCtrlR__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyCtrlWinX, Resources.KeyCtrlWinX__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyCtrlA, Resources.KeyCtrlA__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyCtrlC, Resources.KeyCtrlC__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyCtrlV, Resources.KeyCtrlV__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyCtrlIns, Resources.KeyCtrlIns__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyCtrlAltIns, Resources.KeyCtrlAltIns__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyDel, Resources.KeyDel__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyEsc, Resources.KeyEsc__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyEscLong, Resources.KeyEscLong__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyAnyChar, Resources.KeyAnyChar__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyBackspace, Resources.KeyBackspace__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyCtrlDown, Resources.KeyCtrlDown__));
     result.Add(new ShortcutPanelItem(parent, Resources.KeyCtrlUp, Resources.KeyCtrlUp__));
     foreach (var pair in App.Resolve <IAddonManager>().PanelItems)
     {
         foreach (var menuItem in pair.Value.ContextMenu)
         {
             if (!string.IsNullOrEmpty(menuItem.ShortcutKeys))
             {
                 var shortcut = new ShortcutPanelItem(parent, menuItem.ShortcutKeys, App.TR.Translate(menuItem.Text));
                 shortcut.Context = SuppressPostfix(pair.Key, PANEL_ITEM_SUFFIX);
                 if (menuItem.ProgramValue != null)
                 {
                     shortcut.CustomImageName = string.Format(CultureInfo.InvariantCulture, PanelImageNames.ADDON_FMT, menuItem.ProgramValue.Id);
                 }
                 result.Add(shortcut);
             }
         }
     }
 }
Beispiel #28
0
 public FilePanelItem(PanelItemBase parent, string fileName) : base(parent)
 {
     FileName = fileName;
 }
Beispiel #29
0
 public void SyncFill(PanelItemBase parent, ICollection <PanelItemBase> result)
 {
 }
Beispiel #30
0
 public bool IsParentAccepted(PanelItemBase parent)
 {
     return(parent is WorkspaceRoot || (parent is UserPanelItem && !(parent.Parent is WorkspacePanelItem)));
 }