Esempio n. 1
0
        public ACL_Control(Form _owner, FilesystemObject _object, int _idUser)
        {
            InitializeComponent();

            //_owner.Enabled = false;

            mOwner      = _owner;
            mMetaObject = _object;
            mUserID     = _idUser;

            objectNameLable.Text   = mMetaObject.mFilepath;
            ownerTextBox.Text      = mMetaObject.mUid.ToString();
            ownerGroupTextBox.Text = mMetaObject.mGid.ToString();

            int mask = 32;

            for (int i = 0; i < checkedListBox.Items.Count; ++i)
            {
                if ((mask & mMetaObject.mAccessBitset) != 0)
                {
                    checkedListBox.SetItemChecked(i, true);
                }
                mask = mask >> 1;
            }
        }
Esempio n. 2
0
        private void Delete_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                ListViewItem item = listView1.SelectedItems[0];
                if (item != null)
                {
                    FilesystemObject metaObject = (FilesystemObject)item.Tag;
                    if (metaObject != null)
                    {
                        var             server = new NavigatorIServiceClient();
                        OperationResult result = new OperationResult();
                        server.DeleteObject(-1, mCurrDirectoryData.currPath,
                                            -1, mUserID, "", metaObject,
                                            out result);
                        if (result != null && result.mErrCode == 0)
                        {
                            refreshButton_Click(sender, e);
                        }
                        else if (result != null)
                        {
                            MessageBox.Show(result.mErrMessage);
                        }

                        server.Close();
                    }
                }
            }
        }
Esempio n. 3
0
        private void changeACLButton_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                ListViewItem item = listView1.SelectedItems[0];
                if (item != null)
                {
                    FilesystemObject metaObject = (FilesystemObject)(item.Tag);

                    if (metaObject != null)
                    {
                        ACL_Control control = new ACL_Control(this, metaObject, mUserID);
                        if (control.ShowDialog() == DialogResult.OK)
                        {
                            refreshButton_Click(sender, e);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        private void manFileInfo()
        {
            if (listView1.SelectedItems.Count > 0)
            {
                ListViewItem item = listView1.SelectedItems[0];
                if (item != null)
                {
                    FilesystemObject metaObject = (FilesystemObject)(item.Tag);

                    if (metaObject != null)
                    {
                        setFilesystemObjInfo
                            (metaObject.mIsDirFlag ? "" : metaObject.mFilesize.ToString() + " bytes",
                            metaObject.mIsDirFlag ? "Directory" : "File"
                            );
                    }
                }
            }
            else
            {
                clearFilesystemObjInfo();
            }
        }
Esempio n. 5
0
        private void loadButton_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                ListViewItem item = listView1.SelectedItems[0];
                if (item != null)
                {
                    FilesystemObject metaObject = (FilesystemObject)item.Tag;

                    if (metaObject != null)
                    {
                        var server      = new NavigatorIServiceClient();
                        var serverState = server.State;
                        if (metaObject != null)
                        {
                            /*OperationResult result = new OperationResult();
                             * var remoteFile = server.DownloadFile(-1, -1, mUserID, "", metaObject, "", out result);*/
                            Stream          remoteFile       = null;
                            OperationResult result           = new OperationResult();
                            int             originalFilesize = 0;
                            var             fsMetaObject     = server.DownloadFile(metaObject.mFilepath,
                                                                                   mUserID, out originalFilesize,
                                                                                   out result, out remoteFile);
                            if (result != null && result.mErrCode == 0)
                            {
                                //refreshButton_Click(sender, e);

                                var saveFileDialog = new SaveFileDialog();
                                saveFileDialog.FileName = metaObject.mFilepath
                                                          .Substring(metaObject.mFilepath.LastIndexOf('\\') + 1);
                                if (saveFileDialog.ShowDialog() == DialogResult.OK)
                                {
                                    string filepathDownloaded = saveFileDialog.FileName;
                                    filepathDownloaded = AppDomain.CurrentDomain.BaseDirectory +
                                                         "\\" + filepathDownloaded.Substring(filepathDownloaded.LastIndexOf('\\') + 1);
                                    if (filepathDownloaded != null && filepathDownloaded.Equals("") == false)
                                    {
                                        using (FileStream saveDownloadedEncFile =
                                                   new FileStream(filepathDownloaded, FileMode.Create, FileAccess.Write))
                                        {
                                            try
                                            {
                                                byte[] buffer         = new byte[6500];
                                                int    bytesRead      = 0;
                                                int    totalBytesRead = 0;
                                                do
                                                {
                                                    buffer    = new byte[6500];
                                                    bytesRead = remoteFile.Read(buffer, 0, buffer.Length);

                                                    if (bytesRead > 0)
                                                    {
                                                        saveDownloadedEncFile.Write(buffer, 0, bytesRead);
                                                    }
                                                    totalBytesRead += bytesRead;
                                                } while (bytesRead > 0);
                                            }
                                            catch (Exception ex)
                                            {
                                            }
                                        }

                                        if (mComplexKey != null)
                                        {
                                            /*byte[] encryptedBuffer = null;
                                             * encryptedBuffer = File.ReadAllBytes(filepathDownloaded);
                                             * if ((encryptedBuffer.Length % 16) != 0)
                                             * {
                                             *  byte[] tmpBuf = new byte[encryptedBuffer.Length + (16 - encryptedBuffer.Length % 16)];
                                             *  Array.Copy(encryptedBuffer, tmpBuf, encryptedBuffer.Length);
                                             *  encryptedBuffer = tmpBuf;
                                             * }
                                             * byte[] decryptedBuffer = null;
                                             * Crypto.AES_Decrypt(encryptedBuffer, ref decryptedBuffer, mComplexKey);
                                             * FileStream fs = new FileStream(saveFileDialog.FileName, FileMode.Create, FileAccess.Write);
                                             * fs.Write(decryptedBuffer, 0, originalFilesize);
                                             * fs.Flush();
                                             * fs.Close();*/

                                            Crypto.AES_Decrypt(filepathDownloaded, saveFileDialog.FileName, mComplexKey);
                                        }
                                        else
                                        {
                                            FileInfo fi = new FileInfo(saveFileDialog.FileName);
                                            if (fi.Exists)
                                            {
                                                fi.Delete();
                                            }
                                            File.Copy(filepathDownloaded, saveFileDialog.FileName);
                                        }

                                        FileInfo fi2 = new FileInfo(filepathDownloaded);
                                        fi2.Delete();

                                        MessageBox.Show("Ok!");
                                    }
                                }
                            }
                            else if (result != null)
                            {
                                MessageBox.Show(result.mErrMessage);
                            }
                        }


                        server.Close();
                    }
                }
            }
        }