示例#1
0
        private void acDelete_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            // get the sharename
            ListViewItem Item = GetSelectedItem();

            if (Item == null)
            {
                return;
            }
            string   sShareName = (string)Item.SubItems[0].Text;
            Hostinfo hn         = ctx as Hostinfo;

            // first, prompt for confirmation
            string sMsg = string.Format(Resources.Prompt_DeleteShare, sShareName);

            if (container.Prompt(sMsg, MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return;
            }
            // delete and refresh
            if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
            {
                SharesAPI.DeleteShare(IntPtr.Zero, hn.creds, hn.hostName, sShareName);
            }
            else
            {
                SharesAPI.DeleteShare(plugin.fileHandle.Handle, hn.creds, hn.hostName, sShareName);
            }

            Refresh();
        }
示例#2
0
        public override void Refresh()
        {
            base.Refresh();
            Hostinfo hn = ctx as Hostinfo;

            if (nodeType == FileShareManagerIPlugIn.PluginNodeType.SHARES)
            {
                Dictionary <int, string[]> ShareList = null;

                if (lvSharePage.Items.Count != 0)
                {
                    lvSharePage.Items.Clear();
                }

                if (Configurations.currentPlatform != LikewiseTargetPlatform.Windows)
                {
                    if (plugin.fileHandle != null && plugin.fileHandle.Handle != null)
                    {
                        ShareList = SharesAPI.EnumShares(plugin.fileHandle.Handle, hn.creds, hn.hostName);
                    }
                    else
                    {
                        Logger.Log("SharesPage.Refresh: SharesAPI.Handle returned null", Logger.LogLevel.Error);
                        return;
                    }
                }
                else
                {
                    ShareList = SharesAPI.EnumShares(IntPtr.Zero, hn.creds, hn.hostName);
                }

                if (ShareList == null)
                {
                    Logger.Log("SharesPage.Refresh: SharesAPI.EnumShares returned null", Logger.LogLevel.Error);
                    return;
                }

                foreach (int i in ShareList.Keys)
                {
                    ListViewItem lvItem = new ListViewItem(ShareList[i]);
                    lvSharePage.Items.Add(lvItem);
                }
            }
            else
            {
                ListViewItem[] itemlist = new ListViewItem[treeNode.Nodes.Count];
                int            index    = 0;

                foreach (LACTreeNode node in treeNode.Nodes)
                {
                    ListViewItem item = new ListViewItem(new string[] { node.Text });
                    itemlist[index] = item;
                    index++;
                }
                if (itemlist.Length != 0)
                {
                    lvSharePage.Items.AddRange(itemlist);
                }
            }
        }
示例#3
0
        private void acViewShare_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ListViewItem Item = GetSelectedItem();

            if (Item == null)
            {
                return;
            }
            string   sShare = (string)Item.SubItems[0].Text;
            Hostinfo hn     = ctx as Hostinfo;

            if (Configurations.currentPlatform == LikewiseTargetPlatform.Windows)
            {
                SharesAPI.ViewShare(hn.creds, hn.hostName, sShare);
            }
            else
            {
                if (File.Exists(sShare))
                {
                    ProcessStartInfo startInfo = new ProcessStartInfo("nautilus", sShare);
                    startInfo.RedirectStandardOutput = true;
                    startInfo.UseShellExecute        = false;
                    startInfo.Verb        = "open";
                    startInfo.WindowStyle = ProcessWindowStyle.Normal;
                    Process.Start(startInfo);
                    return;
                }
            }
        }
示例#4
0
        private void acClose_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (lvFilePage.SelectedItems.Count != 1)
            {
                return;
            }

            // get the accessing machine and user name of the session to close
            ListViewItem Item    = lvFilePage.SelectedItems[0];
            string       sFileId = (string)Item.SubItems[4].Text;

            try
            {
                int      nFileId = int.Parse(sFileId);
                Hostinfo hn      = ctx as Hostinfo;

                if (plugin.fileHandle != null)
                {
                    SharesAPI.CloseFile(IntPtr.Zero, hn.creds, hn.hostName, nFileId);
                }
                else
                {
                    SharesAPI.CloseFile(plugin.fileHandle.Handle, hn.creds, hn.hostName, nFileId);
                }

                Refresh();
            }
            catch (Exception ex)
            {
                string sMsg = string.Format(Resources.Error_UnableToCloseFile, ex.Message);
                container.ShowError(sMsg);
            }
        }
示例#5
0
        private void On_MenuClick(object sender, EventArgs e)
        {
            MenuItem m = sender as MenuItem;

            if (m != null && m.Text.Trim().Equals("&Properties"))
            {
                ListViewItem Item = GetSelectedItem();

                if (Item == null)
                {
                    return;
                }

                string   sShare    = (string)Item.SubItems[0].Text;
                string[] Shareinfo = null;
                Hostinfo hn        = ctx as Hostinfo;

                if (plugin.fileHandle != null)
                {
                    Shareinfo = SharesAPI.GetShareInfo(plugin.fileHandle.Handle, sShare, hn.hostName);
                }
                else
                {
                    Shareinfo = SharesAPI.GetShareInfo(IntPtr.Zero, sShare, hn.hostName);
                }

                if (Shareinfo != null && Shareinfo.Length != 0)
                {
                    if (Shareinfo[0].Equals("share"))
                    {
                        SharePropertiesDlg shareDlg = new SharePropertiesDlg(container, this, plugin, hn);
                        shareDlg.SetData(hn.creds, sShare, Shareinfo);
                        shareDlg.ShowDialog(this);
                    }
                    else
                    {
                        string sMsg = "This has been shared for administrative purposes.\n The Share permissions and file security cannot be set";
                        container.ShowMessage(sMsg);
                    }
                }
            }

            if (m != null && m.Text.Trim().Equals("&Help"))
            {
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.UseShellExecute = true;
                psi.FileName        = CommonResources.GetString("LAC_Help");
                psi.Verb            = "open";
                psi.WindowStyle     = ProcessWindowStyle.Normal;
                Process.Start(psi);
                return;
            }

            if (m != null && m.Text.Trim().Equals("&Refresh"))
            {
                treeNode.sc.ShowControl(treeNode);
            }
        }
示例#6
0
        private void acLaunchMMC_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Hostinfo hn = ctx as Hostinfo;

            SharesAPI.RunMMC(hn.creds, hn.hostName);
        }
示例#7
0
        public override void Refresh()
        {
            base.Refresh();
            Hostinfo hn = ctx as Hostinfo;

            const int NUM_COLUMNS = 5;

            //pixels to use to give a visible margin between columns
            const int MARGIN = 10;

            if (lvFilePage.Items.Count != 0)
            {
                lvFilePage.Items.Clear();
            }

            if (!String.IsNullOrEmpty(hn.hostName))
            {
                this.lblCaption.Text = string.Format(this.lblCaption.Text, hn.hostName);
            }
            Dictionary <int, string[]> FileList = null;

            if (Configurations.currentPlatform != LikewiseTargetPlatform.Windows)
            {
                if (plugin.fileHandle != null && plugin.fileHandle.Handle != null)
                {
                    FileList = SharesAPI.EnumFiles(plugin.fileHandle.Handle, hn.creds, hn.hostName);
                }
                else
                {
                    Logger.Log("FilesPage.Refresh: SharesAPI.Handle returned null", Logger.LogLevel.Error);
                    return;
                }
            }
            else
            {
                FileList = SharesAPI.EnumFiles(IntPtr.Zero, hn.creds, hn.hostName);
            }

            if (FileList == null)
            {
                Logger.Log("FilesPage.Refresh: FileList == null", Logger.LogLevel.Error);
                return;
            }

            foreach (int i in FileList.Keys)
            {
                ListViewItem lvItem = new ListViewItem(FileList[i]);
                lvFilePage.Items.Add(lvItem);
            }

            int minColumnWidth = (this.Width / NUM_COLUMNS) / 2;

            foreach (ColumnHeader ch in lvFilePage.Columns)
            {
                if (ch.Index != 4)
                {
                    if (ch.Width + MARGIN < minColumnWidth)
                    {
                        ch.Width = minColumnWidth;
                    }
                    else
                    {
                        ch.Width += MARGIN;
                    }
                }
            }

            //HACK: make sure that rightmost column is always covers
            //any remaining space on the right side of the list view
            lvFilePage.Columns[NUM_COLUMNS - 2].Width = this.Width;
        }
示例#8
0
        private void On_MenuClick(object sender, EventArgs e)
        {
            MenuItem m = sender as MenuItem;

            if (m != null && m.Text.Trim().Equals("Disconnect &All Open Files"))
            {
                DialogResult dlg = MessageBox.Show(this, "Are you sure you wish to close all files?",
                                                   CommonResources.GetString("Caption_Console"),
                                                   MessageBoxButtons.YesNo, MessageBoxIcon.None,
                                                   MessageBoxDefaultButton.Button1);

                if (dlg == DialogResult.OK)
                {
                    Hostinfo hn = ctx as Hostinfo;

                    foreach (ListViewItem Item in lvFilePage.Items)
                    {
                        string sFileId = (string)Item.SubItems[4].Text;

                        try
                        {
                            int nFileId = int.Parse(sFileId);

                            if (plugin.fileHandle != null)
                            {
                                SharesAPI.CloseFile(IntPtr.Zero, hn.creds, hn.hostName, nFileId);
                            }
                            else
                            {
                                SharesAPI.CloseFile(plugin.fileHandle.Handle, hn.creds, hn.hostName, nFileId);
                            }
                        }
                        catch (Exception ex)
                        {
                            string sMsg = string.Format(Resources.Error_UnableToCloseFile, ex.Message);
                            container.ShowError(sMsg);
                            break;
                        }
                    }
                    //Just do refresh once the files got closed on the treenode.
                    treeNode.sc.ShowControl(treeNode);
                }
            }

            if (m != null && m.Text.Trim().Equals("&Refresh"))
            {
                treeNode.sc.ShowControl(treeNode);
                return;
            }

            if (m != null && m.Text.Trim().Equals("&Help"))
            {
                ProcessStartInfo psi = new ProcessStartInfo();
                psi.UseShellExecute = true;
                psi.FileName        = CommonResources.GetString("LAC_Help");
                psi.Verb            = "open";
                psi.WindowStyle     = ProcessWindowStyle.Normal;
                Process.Start(psi);
                return;
            }
        }