Box sub folder handling

This commit is contained in:
Jaex 2014-04-17 02:34:31 +03:00
parent f56ac65fac
commit 6380d013b1
8 changed files with 76 additions and 58 deletions

View file

@ -771,7 +771,7 @@ public UploadResult UploadFile(Stream stream, string fileName)
case FileDestination.Box:
fileUploader = new Box(Program.UploadersConfig.BoxOAuth2Info)
{
FolderID = Program.UploadersConfig.BoxFolderID,
FolderID = Program.UploadersConfig.BoxSelectedFolder.id,
Share = Program.UploadersConfig.BoxShare
};
break;

View file

@ -39,7 +39,7 @@ public sealed class Box : FileUploader, IOAuth2
{
type = "folder",
id = "0",
name = "All Files"
name = "Root folder"
};
public OAuth2Info AuthInfo { get; set; }
@ -141,6 +141,11 @@ public BoxFileInfo GetFiles(BoxFileEntry folder)
public BoxFileInfo GetFiles(string id)
{
if (!CheckAuthorization())
{
return null;
}
string url = string.Format("https://api.box.com/2.0/folders/{0}/items", id);
NameValueCollection headers = new NameValueCollection();

View file

@ -183,7 +183,9 @@ private void InitializeComponent()
this.tpGoogleDrive = new System.Windows.Forms.TabPage();
this.cbGoogleDriveIsPublic = new System.Windows.Forms.CheckBox();
this.tpBox = new System.Windows.Forms.TabPage();
this.txtBoxFolderID = new System.Windows.Forms.TextBox();
this.cbBoxShare = new System.Windows.Forms.CheckBox();
this.lvBoxFolders = new HelpersLib.MyListView();
this.chBoxFoldersName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.lblBoxFolderID = new System.Windows.Forms.Label();
this.btnBoxRefreshFolders = new System.Windows.Forms.Button();
this.tpRapidShare = new System.Windows.Forms.TabPage();
@ -356,9 +358,7 @@ private void InitializeComponent()
this.atcGoogleURLShortenerAccountType = new UploadersLib.GUI.AccountTypeControl();
this.ucTwitterAccounts = new UploadersLib.AccountsControl();
this.actRapidShareAccountType = new UploadersLib.GUI.AccountTypeControl();
this.lvBoxFolders = new HelpersLib.MyListView();
this.chBoxFoldersName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.cbBoxShare = new System.Windows.Forms.CheckBox();
this.lblBoxFolderTip = new System.Windows.Forms.Label();
this.tcUploaders.SuspendLayout();
this.tpImageUploaders.SuspendLayout();
this.tcImageUploaders.SuspendLayout();
@ -2058,10 +2058,10 @@ private void InitializeComponent()
//
// tpBox
//
this.tpBox.Controls.Add(this.lblBoxFolderTip);
this.tpBox.Controls.Add(this.cbBoxShare);
this.tpBox.Controls.Add(this.lvBoxFolders);
this.tpBox.Controls.Add(this.oauth2Box);
this.tpBox.Controls.Add(this.txtBoxFolderID);
this.tpBox.Controls.Add(this.lblBoxFolderID);
this.tpBox.Controls.Add(this.btnBoxRefreshFolders);
this.tpBox.Location = new System.Drawing.Point(4, 40);
@ -2072,22 +2072,45 @@ private void InitializeComponent()
this.tpBox.Text = "Box";
this.tpBox.UseVisualStyleBackColor = true;
//
// txtBoxFolderID
// cbBoxShare
//
this.txtBoxFolderID.Location = new System.Drawing.Point(600, 17);
this.txtBoxFolderID.Name = "txtBoxFolderID";
this.txtBoxFolderID.Size = new System.Drawing.Size(104, 20);
this.txtBoxFolderID.TabIndex = 3;
this.txtBoxFolderID.TextChanged += new System.EventHandler(this.txtBoxFolderID_TextChanged);
this.cbBoxShare.AutoSize = true;
this.cbBoxShare.Location = new System.Drawing.Point(16, 232);
this.cbBoxShare.Name = "cbBoxShare";
this.cbBoxShare.Size = new System.Drawing.Size(125, 17);
this.cbBoxShare.TabIndex = 9;
this.cbBoxShare.Text = "Create shareable link";
this.cbBoxShare.UseVisualStyleBackColor = true;
this.cbBoxShare.CheckedChanged += new System.EventHandler(this.cbBoxShare_CheckedChanged);
//
// lvBoxFolders
//
this.lvBoxFolders.AutoFillColumn = true;
this.lvBoxFolders.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.chBoxFoldersName});
this.lvBoxFolders.FullRowSelect = true;
this.lvBoxFolders.Location = new System.Drawing.Point(352, 48);
this.lvBoxFolders.Name = "lvBoxFolders";
this.lvBoxFolders.Size = new System.Drawing.Size(440, 368);
this.lvBoxFolders.TabIndex = 8;
this.lvBoxFolders.UseCompatibleStateImageBehavior = false;
this.lvBoxFolders.View = System.Windows.Forms.View.Details;
this.lvBoxFolders.SelectedIndexChanged += new System.EventHandler(this.lvBoxFolders_SelectedIndexChanged);
this.lvBoxFolders.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvBoxFolders_MouseDoubleClick);
//
// chBoxFoldersName
//
this.chBoxFoldersName.Text = "Folder name";
this.chBoxFoldersName.Width = 435;
//
// lblBoxFolderID
//
this.lblBoxFolderID.AutoSize = true;
this.lblBoxFolderID.Location = new System.Drawing.Point(488, 21);
this.lblBoxFolderID.Name = "lblBoxFolderID";
this.lblBoxFolderID.Size = new System.Drawing.Size(103, 13);
this.lblBoxFolderID.Size = new System.Drawing.Size(81, 13);
this.lblBoxFolderID.TabIndex = 2;
this.lblBoxFolderID.Text = "Folder ID for upload:";
this.lblBoxFolderID.Text = "Selected folder:";
//
// btnBoxRefreshFolders
//
@ -3854,35 +3877,14 @@ private void InitializeComponent()
this.actRapidShareAccountType.Size = new System.Drawing.Size(214, 29);
this.actRapidShareAccountType.TabIndex = 16;
//
// lvBoxFolders
// lblBoxFolderTip
//
this.lvBoxFolders.AutoFillColumn = true;
this.lvBoxFolders.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.chBoxFoldersName});
this.lvBoxFolders.FullRowSelect = true;
this.lvBoxFolders.Location = new System.Drawing.Point(352, 48);
this.lvBoxFolders.Name = "lvBoxFolders";
this.lvBoxFolders.Size = new System.Drawing.Size(440, 400);
this.lvBoxFolders.TabIndex = 8;
this.lvBoxFolders.UseCompatibleStateImageBehavior = false;
this.lvBoxFolders.View = System.Windows.Forms.View.Details;
this.lvBoxFolders.SelectedIndexChanged += new System.EventHandler(this.lvBoxFolders_SelectedIndexChanged);
//
// chBoxFoldersName
//
this.chBoxFoldersName.Text = "Folder name";
this.chBoxFoldersName.Width = 435;
//
// cbBoxShare
//
this.cbBoxShare.AutoSize = true;
this.cbBoxShare.Location = new System.Drawing.Point(16, 232);
this.cbBoxShare.Name = "cbBoxShare";
this.cbBoxShare.Size = new System.Drawing.Size(125, 17);
this.cbBoxShare.TabIndex = 9;
this.cbBoxShare.Text = "Create shareable link";
this.cbBoxShare.UseVisualStyleBackColor = true;
this.cbBoxShare.CheckedChanged += new System.EventHandler(this.cbBoxShare_CheckedChanged);
this.lblBoxFolderTip.AutoSize = true;
this.lblBoxFolderTip.Location = new System.Drawing.Point(352, 424);
this.lblBoxFolderTip.Name = "lblBoxFolderTip";
this.lblBoxFolderTip.Size = new System.Drawing.Size(304, 13);
this.lblBoxFolderTip.TabIndex = 10;
this.lblBoxFolderTip.Text = "Note: You can double click folder name to go inside that folder.";
//
// UploadersConfigForm
//
@ -4191,7 +4193,6 @@ private void InitializeComponent()
private System.Windows.Forms.TextBox txtRapidShareFolderID;
private System.Windows.Forms.Label lblRapidShareFolderID;
private System.Windows.Forms.TabPage tpBox;
private System.Windows.Forms.TextBox txtBoxFolderID;
private System.Windows.Forms.Label lblBoxFolderID;
private System.Windows.Forms.Button btnBoxRefreshFolders;
private System.Windows.Forms.CheckBox cbDropboxAutoCreateShareableLink;
@ -4333,5 +4334,6 @@ private void InitializeComponent()
private HelpersLib.MyListView lvBoxFolders;
private System.Windows.Forms.ColumnHeader chBoxFoldersName;
private System.Windows.Forms.CheckBox cbBoxShare;
private System.Windows.Forms.Label lblBoxFolderTip;
}
}

View file

@ -534,11 +534,6 @@ private void cbBoxShare_CheckedChanged(object sender, EventArgs e)
Config.BoxShare = cbBoxShare.Checked;
}
private void txtBoxFolderID_TextChanged(object sender, EventArgs e)
{
Config.BoxFolderID = txtBoxFolderID.Text;
}
private void btnBoxRefreshFolders_Click(object sender, EventArgs e)
{
BoxListFolders();
@ -552,7 +547,21 @@ private void lvBoxFolders_SelectedIndexChanged(object sender, EventArgs e)
BoxFileEntry file = lvi.Tag as BoxFileEntry;
if (file != null)
{
txtBoxFolderID.Text = file.id;
lblBoxFolderID.Text = "Selected folder: " + file.name;
}
}
}
private void lvBoxFolders_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && lvBoxFolders.SelectedItems.Count > 0)
{
ListViewItem lvi = lvBoxFolders.SelectedItems[0];
BoxFileEntry file = lvi.Tag as BoxFileEntry;
if (file != null)
{
lvBoxFolders.Items.Clear();
BoxListFolders(file);
}
}
}

View file

@ -242,9 +242,6 @@
With this option, objects are cheaper to store, but have 99.99% durability, instead of 99.999999999%.
This means that they may be lost from Amazon S3 at some point.</value>
</data>
<metadata name="ttHelpTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>72</value>
</metadata>

View file

@ -296,7 +296,7 @@ public void LoadSettings(UploadersConfig uploadersConfig)
}
cbBoxShare.Checked = Config.BoxShare;
txtBoxFolderID.Text = Config.BoxFolderID;
lblBoxFolderID.Text = "Selected folder: " + Config.BoxSelectedFolder.name;
// Ge.tt

View file

@ -725,6 +725,13 @@ public void BoxAuthRefresh()
}
public void BoxListFolders()
{
lvBoxFolders.Items.Clear();
BoxAddFolder(Box.RootFolder);
BoxListFolders(Box.RootFolder);
}
public void BoxListFolders(BoxFileEntry fileEntry)
{
if (!OAuth2Info.CheckOAuth(Config.BoxOAuth2Info))
{
@ -732,10 +739,8 @@ public void BoxListFolders()
}
else
{
lvBoxFolders.Items.Clear();
BoxAddFolder(Box.RootFolder);
Box box = new Box(Config.BoxOAuth2Info);
BoxFileInfo files = box.GetFiles(Box.RootFolder);
BoxFileInfo files = box.GetFiles(fileEntry);
if (files != null && files.entries != null && files.entries.Length > 0)
{
foreach (BoxFileEntry folder in files.entries.Where(x => x.type == "folder"))

View file

@ -147,7 +147,7 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
// Box
public OAuth2Info BoxOAuth2Info = null;
public string BoxFolderID = "0";
public BoxFileEntry BoxSelectedFolder = Box.RootFolder;
public bool BoxShare = true;
// Ge.tt