public void Init(Dropbox dropBox, Dropbox.DropData _data, int id) { field.text = _data.title; GetComponent<Button>().onClick.AddListener(() => { OnSelected(dropBox, _data, id); }); }
public ActionResult AuthorizeDropbox() { Dropbox dropbox = new Dropbox(); string url = dropbox.BuildAuthorizationUrl(Url.Action("Index", "Dropbox", null, Request.Url.Scheme)); Session[DROPBOX_TOKEN] = dropbox.Token; return(Redirect(url)); }
public DropboxFilesForm(OAuthInfo oauth, string path = null) { InitializeComponent(); dropbox = new Dropbox(oauth); ilm = new ImageListManager(lvDropboxFiles); if (path != null) { Shown += (sender, e) => OpenDirectory(path); } }
void AddConnectionBox() { var uri = Dropbox.GetAuthPageAddress(); Messenger.Default.Send <NotificationMessageWithCallback>(new NotificationMessageWithCallback(uri.ToString(), new Action <string>(async(string uri1) => { Dropbox.SetAccessToken(new Uri(uri1)); User = await Dropbox.GetUserInfoAsync(); RaisePropertyChanged(() => User); })), "GetAuth"); }
private ActionResult AuthenticationCallback() { Session[EXACT_AUTH_STATE] = client.ProcessUserAuthorization(this.Request); // Call ExactOnline SDK ExactOnlineClient exact = new ExactOnlineClient(ConfigurationManager.AppSettings["exactOnlineUrl"], AccessTokenManager); UserLogin token = Session[DropboxController.DROPBOX_ACCESS_TOKEN] as UserLogin; List <DocumentCategory> categories = exact.For <DocumentCategory>().Select(new string[] { "ID", "Description" }).Get(); Dropbox dropbox = new Dropbox(token, true); IEnumerable <string> fileNames = dropbox.GetNewDocumentNames(); Dictionary <Guid, string> newReferences = new Dictionary <Guid, string>(); foreach (string fileName in fileNames) { byte[] file = dropbox.GetFileBytes(fileName); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName); Document document = new Document() { Subject = fileNameWithoutExtension, Body = fileNameWithoutExtension, Type = 55, DocumentDate = DateTime.Now.Date, Category = categories[3].ID }; bool createdDocument = exact.For <Document>().Insert(ref document); DocumentAttachment attachment = new DocumentAttachment() { Document = document.ID, FileName = fileName, FileSize = (double)file.Length, Attachment = file }; bool createdAttachment = exact.For <DocumentAttachment>().Insert(ref attachment); newReferences.Add(document.ID, fileName); } Dictionary <Guid, string> existingReferences = dropbox.GetExactOnlineReferences(); dropbox.UpdateExactOnlineReferences(existingReferences, newReferences); return(View()); // Later, if necessary: // bool success = client.RefreshAuthorization(auth); }
private void tsmiCopyPublicLink_Click(object sender, EventArgs e) { if (lvDropboxFiles.SelectedItems.Count > 0) { DropboxContentInfo content = lvDropboxFiles.SelectedItems[0].Tag as DropboxContentInfo; if (content != null && !content.Is_dir && content.Path.StartsWith("/Public/", StringComparison.InvariantCultureIgnoreCase)) { string url = Dropbox.GetPublicURL(dropboxAccountInfo.Uid, content.Path); ClipboardHelpers.CopyText(url); } } }
//[Test] public void SmokeTest() { Reporting.ReportHeader("Engage Smoke Test"); // Login Reporting.TestName("Login"); _itcActions.ITC_Login(_startUp.driver); // Enrol Subject Reporting.TestName("Enrol"); int subject1 = _itcActions.ITC_EnrolSubject(_startUp.driver); //check last event date Reporting.TestName("Check last event date"); var LastEvent = DateTime.Today.AddDays(4).ToString("dd MMMM yyyy"); _itcActions.ITC_CheckLastEventDate(subject1, LastEvent, _startUp.driver); // View Subject Reporting.TestName("View Subject"); _itcActions.ITC_ViewSubject(subject1, _startUp.driver); // Check the Help Text //_itcActions.ITC_CheckHelpText(driver); //currently there is no help text displayed on the site so need to run test // Edit Subject Reporting.TestName("Edit Subject"); _itcActions.ITC_EditSubject(subject1, _startUp.driver); //Add a test to view scheduled messages // Withdraw Reporting.TestName("Withdraw"); _itcActions.ITC_Withdraw(subject1, _startUp.driver); Reporting.ReportFooter(); //Delete all JPEGS in folder string sourcePath = AppDomain.CurrentDomain.BaseDirectory.ToString(); string htmlLink = "file:///" + sourcePath + _startUp.resultsFileName; //locate the file string fileName = "_TestReport" + _startUp.resultsFileName + ".pdf"; HtmlToPdf conver = new HtmlToPdf(); //Initialisethe object PdfDocument doc = conver.ConvertUrl(htmlLink); // convert the link, you can convert raw HTML if you wish doc.Save(fileName); //save the file doc.Close(); //close Dropbox.uploadFile(fileName); //upolad to dropbox _startUp.Teardown(_startUp.driver); }
public DropboxFilesForm(OAuthInfo oauth, string path, DropboxAccountInfo accountInfo) { InitializeComponent(); Icon = Resources.Dropbox; dropbox = new Dropbox(oauth); dropboxAccountInfo = accountInfo; ilm = new ImageListManager(lvDropboxFiles); if (path != null) { Shown += (sender, e) => OpenDirectory(path); } }
// // GET: /Dropbox/ public ActionResult Index() { UserLogin token = Session["dropboxToken"] as UserLogin; Dropbox dropbox = new Dropbox(token); Session.Remove(DROPBOX_TOKEN); // We no longer need this one Session[DROPBOX_ACCESS_TOKEN] = dropbox.Token; int newFilesCount = dropbox.GetNewDocumentsCount(); ViewBag.NewFilesCount = newFilesCount; return(View()); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); servicePosition = Intent.GetIntExtra("Service", 0); if (servicePosition == 1) { GoogleDrive googleDrive = new GoogleDrive(this, "[Client Id]", "", "com.cloudrail.unifiedcloudstorage:/oauth2redirect", "state"); googleDrive.UseAdvancedAuthentication(); service = googleDrive; } else if (servicePosition == 2) { service = new Box(this, "[Client Id]", "[Client Secret]"); } else if (servicePosition == 3) { service = new OneDrive(this, "[Application Id]", "[Application Secret]"); } else if (servicePosition == 4) { service = new Egnyte(this, "[Domain]", "[Client Id]", "[Client Secret]"); } else { Dropbox dropbox = new Dropbox(this, "zsoojeklqxn3zrc", "b8jjaf2d62kbdnf", "https://auth.cloudrail.com/com.cloudrail.unifiedcloudstorage", "state"); dropbox.UseAdvancedAuthentication(); service = dropbox; } serviceValue = servicePosition.ToString(); //If Service exist in Shared Prefence load, it. LoadService(); //Login Method Optional //LoginMethod(); //Get Files / Folder at Path. "/" = root path GetChildrenAtPath("/"); }
private void UpdateDropboxStatus() { if (OAuthInfo.CheckOAuth(Config.DropboxOAuthInfo) && Config.DropboxAccountInfo != null) { StringBuilder sb = new StringBuilder(); sb.AppendLine("Login status: Successful"); sb.AppendLine("Email: " + Config.DropboxAccountInfo.Email); sb.AppendLine("Name: " + Config.DropboxAccountInfo.Display_name); sb.AppendLine("User ID: " + Config.DropboxAccountInfo.Uid.ToString()); string uploadPath = GetDropboxUploadPath(); sb.AppendLine("Upload path: " + uploadPath); sb.AppendLine("Download path: " + Dropbox.GetDropboxURL(Config.DropboxAccountInfo.Uid, uploadPath, "{Filename}")); lblDropboxStatus.Text = sb.ToString(); btnDropboxShowFiles.Enabled = true; } else { lblDropboxStatus.Text = "Login status: Authorize required"; } }
public void DropboxAuthOpen() { try { OAuthInfo oauth = new OAuthInfo(APIKeys.DropboxConsumerKey, APIKeys.DropboxConsumerSecret); string url = new Dropbox(oauth).GetAuthorizationURL(); if (!string.IsNullOrEmpty(url)) { Config.DropboxOAuthInfo = oauth; ZAppHelper.LoadBrowserAsync(url); btnDropboxCompleteAuth.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
bool SaveUploadDropbox() { Dropbox.AutoCreateFolder(item.To.node.Parent); Dropbox_Request_UploadSessionFinish session_finish = new Dropbox_Request_UploadSessionFinish( new Dropbox_upload(item.To.node.GetFullPathString(false)), new Dropbox_Request_UploadSessionAppend(item.UploadID, item.SizeWasTransfer) ); IDropbox_Response_MetaData json_ = ((DropboxRequestAPIv2)clientTo).upload_session_finish(session_finish); long size = json_.size; if (size == item.From.node.Info.Size) { return(true); } else { item.ErrorMsg = "File size was upload not match."; return(false); } }
public void SelectStorage(DocumentStorage storage) { CloudRail.AppKey = "5ad616fe53d06b4cef4eb35c"; switch (storage) { case DocumentStorage.Dropbox: Dropbox dropbox = new Dropbox( new LocalReceiver(port), "yr0vm4fdyc5m5wq", "ec81w1sde5psdyn", "http://localhost:" + port + "/", "someState" ); service = dropbox; break; case DocumentStorage.GoogleDrive: GoogleDrive googledrive = new GoogleDrive( new LocalReceiver(port), "452884182377-af4j4heo22mgo04vvg95ol547tih4md7.apps.googleusercontent.com", "1TKbAAkPHtf4DLRdH3os0hL8", "http://localhost:" + port + "/", "someState" ); service = googledrive; break; case DocumentStorage.OneDrive: OneDrive onedrive = new OneDrive( new LocalReceiver(port), "488bea49-a172-45df-bb6f-a9efb228a4e6", "jD57;nfrylvEJAIWP807[;#", "http://localhost:" + port + "/", "someState" ); service = onedrive; break; } }
public async Task WritesFile(string guid = null) { if (guid == null) { guid = string.Format("{0}", Guid.NewGuid()); } // Manually set the test credential; in the real-world, QBO will store them in it's CredentialCache. var dropbox = new Dropbox(Config, null) { Credential = credential }; using (var stream = new CacheStream("Samples/HelloDropbox.html", System.IO.FileMode.Open, System.IO.FileAccess.Read)) { // Make sure we have a unique file, so folks can see the new file in Dropbox var info = await dropbox.WriteAsync(stream, string.Format("HelloDropbox.{0}.html", guid)); Assert.IsNotNull(info); } }
public void updateDropbox(Dropbox box) { //foreach (var key in needToUnlock.Keys) //{ // if (needToUnlock[key] == true) // { // //needToUnlock[key] = false; // box.dropboxType = DropboxType.unlock; // box.unlockPlant = key; // return; // } //} //box.dropboxType = DropboxType.resource; //PlantProperty[] dropProperties = new PlantProperty[]{ // PlantProperty.n, PlantProperty.p, PlantProperty.water, //}; //var typeRandom = Random.Range(0, 3); //box.resource = new Dictionary<PlantProperty, int>() { // {dropProperties[typeRandom], Random.Range(5, 10) }, //}; }
public void DropboxAuthComplete() { if (Config.DropboxOAuthInfo != null && !string.IsNullOrEmpty(Config.DropboxOAuthInfo.AuthToken) && !string.IsNullOrEmpty(Config.DropboxOAuthInfo.AuthSecret)) { Dropbox dropbox = new Dropbox(Config.DropboxOAuthInfo); bool result = dropbox.GetAccessToken(); if (result) { DropboxAccountInfo account = dropbox.GetAccountInfo(); if (account != null) { Config.DropboxAccountInfo = account; Config.DropboxUploadPath = txtDropboxPath.Text; UpdateDropboxStatus(); MessageBox.Show("Login successful.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } MessageBox.Show("GetAccountInfo failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Login failed.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("You must give access from Authorize page first.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Config.DropboxOAuthInfo = null; UpdateDropboxStatus(); }
public static void Main(string[] args) { CloudRail.AppKey = "[Your Cloudrail Key]"; int port = 8082; String serviceName = SelectService(); Box box = new Box( new LocalReceiver(port), "[Box Client Identifier]", "[Box Client Secret]", "http://localhost:" + port + "/", "someState" ); Dropbox dropbox = new Dropbox( new LocalReceiver(port), "[Dropbox Client Identifier]", "[Dropbox Client Secret]", "http://localhost:" + port + "/", "someState" ); Egnyte egnyte = new Egnyte( new LocalReceiver(port), "[Your Egnyte Domain]", "[Your Egnyte API Key]", "[Your Egnyte Shared Secret]", "http://localhost:" + port + "/", "someState" ); GoogleDrive googledrive = new GoogleDrive( new LocalReceiver(port), "[Google Drive Client Identifier]", "", "http://localhost:" + port + "/", "someState" ); OneDrive onedrive = new OneDrive( new LocalReceiver(port), "[OneDrive Client Identifier]", "[OneDrive Client Secret]", "http://localhost:" + port + "/", "someState" ); OneDriveBusiness onedrivebusiness = new OneDriveBusiness( new LocalReceiver(port), "[OneDrive Business Client Identifier]", "[OneDrive Business Client Secret]", "http://localhost:" + port + "/", "someState" ); PCloud pCloud = new PCloud(new LocalReceiver(port), "[pCloud Client Identifier]", "[pCloud Client Secret]", "http://localhost:" + port + "/", "someState"); service = null; switch (serviceName) { case "1": Console.WriteLine("Selected Service: Box"); service = box; break; case "2": Console.WriteLine("Selected Service: Dropbox"); service = dropbox; break; case "3": Console.WriteLine("Selected Service: Egnyte"); service = egnyte; break; case "4": Console.WriteLine("Selected Service: Google Drive"); service = googledrive; break; case "5": Console.WriteLine("Selected Service: Onedrive"); service = onedrive; break; case "6": Console.WriteLine("Selected Service: Onedrive for business"); service = onedrivebusiness; break; case "7": Console.WriteLine("Selected Service: pCloud"); service = pCloud; break; } Login(); ShowPath(); GetNextUserCommand(); }
/// <summary> /// <para>Once an async_job_id is returned from <see /// cref="Dropbox.Api.Team.Routes.TeamRoutes.GroupsDeleteAsync" />, <see /// cref="Dropbox.Api.Team.Routes.TeamRoutes.GroupsMembersAddAsync" /> , or <see /// cref="Dropbox.Api.Team.Routes.TeamRoutes.GroupsMembersRemoveAsync" /> use this /// method to poll the status of granting/revoking group members' access to group-owned /// resources.</para> /// <para>Permission : Team member management</para> /// </summary> /// <param name="pollArg">The request parameters</param> /// <returns>The task that represents the asynchronous send operation. The TResult /// parameter contains the response from the server.</returns> /// <exception cref="Dropbox.Api.ApiException{GroupsPollError}">Thrown if there is an /// error processing the request; This will contain a <see /// cref="GroupsPollError"/>.</exception> public t.Task<Dropbox.Api.Async.PollEmptyResult> GroupsJobStatusGetAsync(Dropbox.Api.Async.PollArg pollArg) { return this.Transport.SendRpcRequestAsync<Dropbox.Api.Async.PollArg, Dropbox.Api.Async.PollEmptyResult, GroupsPollError>(pollArg, "api", "/team/groups/job_status/get", Dropbox.Api.Async.PollArg.Encoder, Dropbox.Api.Async.PollEmptyResult.Decoder, Dropbox.Api.Team.GroupsPollError.Decoder); }
void Transfer(TransferItem item) { #if DEBUG Console.WriteLine("Transfer items:" + item.From.node.GetFullPathString()); #endif int buffer_length = 32; //default int.TryParse(AppSetting.settings.GetSettingsAsString(SettingsKey.BufferSize), out buffer_length); //get buffer_length from setting item.buffer = item.From.node.GetRoot.NodeType.Type == CloudType.Mega ? new byte[buffer_length * 2048] : new byte[buffer_length * 1024]; //create buffer ExplorerNode rootnodeto = item.To.node.GetRoot; item.byteread = 0; //this.group.items[x].UploadID = "";//resume item.SizeWasTransfer = item.OldTransfer = item.SaveSizeTransferSuccess; //resume item.ErrorMsg = ""; //clear error item.TimeStamp = CurrentMillis.Millis; if (GroupData.status != StatusTransfer.Running) { return; } switch (rootnodeto.NodeType.Type) { case CloudType.LocalDisk: #region LocalDisk ItemsTransferWork.Add(new TransferBytes(item, this)); return; #endregion case CloudType.Dropbox: #region Dropbox int chunksizedb = 25; //default 25Mb int.TryParse(AppSetting.settings.GetSettingsAsString(SettingsKey.Dropbox_ChunksSize), out chunksizedb); item.ChunkUploadSize = chunksizedb * 1024 * 1024; DropboxRequestAPIv2 DropboxClient = Dropbox.GetAPIv2(rootnodeto.NodeType.Email); if (string.IsNullOrEmpty(item.UploadID)) //create upload id { item.byteread = item.From.stream.Read(item.buffer, 0, item.buffer.Length); IDropbox_Request_UploadSessionAppend session = DropboxClient.upload_session_start(item.buffer, item.byteread); item.UploadID = session.session_id; item.SizeWasTransfer += item.byteread; } ItemsTransferWork.Add(new TransferBytes(item, this, DropboxClient)); return; #endregion case CloudType.GoogleDrive: #region GoogleDrive DriveAPIHttprequestv2 gdclient = GoogleDrive.GetAPIv2(rootnodeto.NodeType.Email); GoogleDrive.CreateFolder(item.To.node.Parent); int chunksizeGD = 5; //default int.TryParse(AppSetting.settings.GetSettingsAsString(SettingsKey.GD_ChunksSize), out chunksizeGD); item.ChunkUploadSize = chunksizeGD * 1024 * 1024; if (string.IsNullOrEmpty(item.UploadID)) //create upload id { if (string.IsNullOrEmpty(item.To.node.Parent.Info.ID)) { throw new Exception("Can't get root id."); } string parentid = item.To.node.Parent.Info.ID; string mimeType = Get_mimeType.Get_mimeType_From_FileExtension(item.To.node.GetExtension()); string jsondata = "{\"title\": \"" + item.From.node.Info.Name + "\", \"mimeType\": \"" + mimeType + "\", \"parents\": [{\"id\": \"" + parentid + "\"}]}"; item.UploadID = gdclient.Files.Insert_ResumableGetUploadID(jsondata, mimeType, item.From.node.Info.Size); } ItemsTransferWork.Add(new TransferBytes(item, this, gdclient)); return; #endregion case CloudType.Mega: #region Mega MegaApiClient MegaClient = MegaNz.GetClient(rootnodeto.NodeType.Email); item.buffer = new byte[128 * 1024]; if (string.IsNullOrEmpty(item.UploadID)) //create upload id { MegaNz.AutoCreateFolder(item.To.node.Parent); //auto create folder item.UploadID = MegaClient.RequestUrlUpload(item.From.node.Info.Size); //Make Upload url } item.From.stream = MegaApiClient.MakeEncryptStreamForUpload(item.From.stream, item.From.node.Info.Size, item.dataCryptoMega); //make encrypt stream from file ItemsTransferWork.Add(new TransferBytes(item, this, MegaClient)); return; #endregion } }
/// <summary> /// <para>Begins an asynchronous send to the check job status route.</para> /// </summary> /// <param name="pollArg">The request parameters.</param> /// <param name="callback">The method to be called when the asynchronous send is /// completed.</param> /// <param name="state">A user provided object that distinguished this send from other /// send requests.</param> /// <returns>An object that represents the asynchronous send request.</returns> public sys.IAsyncResult BeginCheckJobStatus(Dropbox.Api.Async.PollArg pollArg, sys.AsyncCallback callback, object state = null) { var task = this.CheckJobStatusAsync(pollArg); return enc.Util.ToApm(task, callback, state); }
/// <summary> /// <para>Returns the status of an asynchronous job.</para> /// <para>Apps must have full Dropbox access to use this endpoint.</para> /// <para>Warning: This endpoint is in beta and is subject to minor but possibly /// backwards-incompatible changes.</para> /// </summary> /// <param name="pollArg">The request parameters</param> /// <returns>The task that represents the asynchronous send operation. The TResult /// parameter contains the response from the server.</returns> /// <exception cref="Dropbox.Api.ApiException{TError}">Thrown if there is an error /// processing the request; This will contain a <see /// cref="Dropbox.Api.Async.PollError"/>.</exception> public t.Task<JobStatus> CheckJobStatusAsync(Dropbox.Api.Async.PollArg pollArg) { return this.Transport.SendRpcRequestAsync<Dropbox.Api.Async.PollArg, JobStatus, Dropbox.Api.Async.PollError>(pollArg, "api", "/sharing/check_job_status", Dropbox.Api.Async.PollArg.Encoder, Dropbox.Api.Sharing.JobStatus.Decoder, Dropbox.Api.Async.PollError.Decoder); }
public void OnSelected(Dropbox dropBoxParent, Dropbox.DropData data, int id) { dropBoxParent.OnSelect(data, id); }
public MainWindow() { InitializeComponent(); ViewModel = new MainWindowViewModel(); WindowState = !App.Settings.StartMinimized ? WindowState.Normal : WindowState.Minimized; this.WhenAnyValue(x => x.WindowState).Where(x => x == WindowState.Minimized).Subscribe(x => Hide()); this.WhenAnyObservable(x => x.ViewModel.VisiblityCommand).Subscribe(_ => { Show(); WindowState = WindowState.Normal; }); this.OneWayBind(ViewModel, x => x.Title, x => x.Title); this.OneWayBind(ViewModel, x => x.IsTopmost, x => x.Topmost); this.OneWayBind(ViewModel, x => x.Title, x => x.TaskbarIcon.ToolTipText); this.OneWayBind(ViewModel, x => x.VisiblityCommand, x => x.TaskbarIcon.DoubleClickCommand); this.OneWayBind(ViewModel, x => x.ImageHistory, x => x.HistoryList.ItemsSource); this.BindCommand(ViewModel, x => x.UploadCommand, x => x.MenuUpload); this.BindCommand(ViewModel, x => x.UploadCommand, x => x.TrayUpload); this.BindCommand(ViewModel, x => x.UploadCommand, x => x.ButtonBrowse); this.BindCommand(ViewModel, x => x.ScreenCommand, x => x.ButtonScreen); this.BindCommand(ViewModel, x => x.SelectionCommand, x => x.ButtonSelection); this.BindCommand(ViewModel, x => x.SettingsCommand, x => x.MenuSettings); this.BindCommand(ViewModel, x => x.SettingsCommand, x => x.TraySettings); this.WhenAnyObservable(x => x.ViewModel.UploadCommand).Subscribe(_ => { var dialog = new OpenFileDialog { InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), Filter = "Image files (*.jpg, *.gif, *.png, *.bmp, *.tiff, *.pdf)|*.jpg;*.gif;*.png;*.bmp;*.tiff;*.pdf", Title = "Upload Images", Multiselect = true }; dialog.ShowDialog(); ViewModel.OpenCommand.Execute(dialog.FileNames); }); this.WhenAnyObservable(x => x.ViewModel.ScreenCommand).Subscribe(async _ => { var file = await CaptureScreen.Capture(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); var previewWindow = new PreviewWindow(file); previewWindow.Show(); }); this.WhenAnyObservable(x => x.ViewModel.SelectionCommand).Subscribe(_ => { var captureWindow = new CaptureWindow(); captureWindow.Show(); }); this.WhenAnyObservable(x => x.ViewModel.SettingsCommand).Subscribe(_ => { var settingsWindow = new SettingsWindow { Owner = this }; settingsWindow.Show(); }); TrayShow.Events().Click.Subscribe(_ => ViewModel.VisiblityCommand.Execute(null)); TrayExit.Events().Click.Subscribe(_ => Close()); MenuExit.Events().Click.Subscribe(_ => Close()); MenuWebsite.Events().Click.Subscribe(_ => Process.Start("https://github.com/vevix/Pixel")); HistoryList.Events().MouseDoubleClick.Subscribe(_ => Process.Start(HistoryList.SelectedValue.ToString())); Dropbox.Events().Drop.Subscribe(e => ViewModel.DropCommand.Execute(e)); MessageBus.Current.Listen <NotificationMessage>() .Subscribe(e => TaskbarIcon.ShowBalloonTip(e.Title, e.Text, e.Icon)); }
public UploadResult UploadFile(Stream stream, string fileName) { FileUploader fileUploader = null; switch (UploadManager.FileUploader) { case FileDestination.Dropbox: NameParser parser = new NameParser { IsFolderPath = true }; string uploadPath = parser.Convert(Dropbox.TidyUploadPath(Program.UploadersConfig.DropboxUploadPath)); fileUploader = new Dropbox(Program.UploadersConfig.DropboxOAuthInfo, uploadPath, Program.UploadersConfig.DropboxAccountInfo) { AutoCreateShareableLink = Program.UploadersConfig.DropboxAutoCreateShareableLink }; break; case FileDestination.RapidShare: fileUploader = new RapidShare(Program.UploadersConfig.RapidShareUsername, Program.UploadersConfig.RapidSharePassword, Program.UploadersConfig.RapidShareFolderID); break; case FileDestination.SendSpace: fileUploader = new SendSpace(ZKeys.SendSpaceKey); switch (Program.UploadersConfig.SendSpaceAccountType) { case AccountType.Anonymous: SendSpaceManager.PrepareUploadInfo(ZKeys.SendSpaceKey); break; case AccountType.User: SendSpaceManager.PrepareUploadInfo(ZKeys.SendSpaceKey, Program.UploadersConfig.SendSpaceUsername, Program.UploadersConfig.SendSpacePassword); break; } break; case FileDestination.Minus: fileUploader = new Minus(Program.UploadersConfig.MinusConfig, new OAuthInfo(ZKeys.MinusConsumerKey, ZKeys.MinusConsumerSecret)); break; case FileDestination.Box: fileUploader = new Box(ZKeys.BoxKey) { AuthToken = Program.UploadersConfig.BoxAuthToken, FolderID = Program.UploadersConfig.BoxFolderID, Share = Program.UploadersConfig.BoxShare }; break; case FileDestination.CustomUploader: if (Program.UploadersConfig.CustomUploadersList.HasValidIndex(Program.UploadersConfig.CustomUploaderSelected)) { fileUploader = new CustomUploader(Program.UploadersConfig.CustomUploadersList[Program.UploadersConfig.CustomUploaderSelected]); } break; case FileDestination.FTP: int index = Program.UploadersConfig.GetFtpIndex(Info.DataType); if (Program.UploadersConfig.FTPAccountList2.HasValidIndex(index)) { fileUploader = new FTPUploader(Program.UploadersConfig.FTPAccountList2[index]); } break; case FileDestination.Email: using (EmailForm emailForm = new EmailForm(Program.UploadersConfig.EmailRememberLastTo ? Program.UploadersConfig.EmailLastTo : string.Empty, Program.UploadersConfig.EmailDefaultSubject, Program.UploadersConfig.EmailDefaultBody)) { if (emailForm.ShowDialog() == DialogResult.OK) { if (Program.UploadersConfig.EmailRememberLastTo) { Program.UploadersConfig.EmailLastTo = emailForm.ToEmail; } fileUploader = new Email { SmtpServer = Program.UploadersConfig.EmailSmtpServer, SmtpPort = Program.UploadersConfig.EmailSmtpPort, FromEmail = Program.UploadersConfig.EmailFrom, Password = Program.UploadersConfig.EmailPassword, ToEmail = emailForm.ToEmail, Subject = emailForm.Subject, Body = emailForm.Body }; } else { IsStopped = true; } } break; } if (fileUploader != null) { PrepareUploader(fileUploader); return(fileUploader.Upload(stream, fileName)); } return(null); }
/// <summary> /// <para>Once an async_job_id is returned from <see /// cref="Dropbox.Api.Team.Routes.TeamRoutes.MembersRemoveAsync" /> , use this to poll /// the status of the asynchronous request.</para> /// <para>Permission : Team member management</para> /// </summary> /// <param name="pollArg">The request parameters</param> /// <returns>The task that represents the asynchronous send operation. The TResult /// parameter contains the response from the server.</returns> /// <exception cref="Dropbox.Api.ApiException{Dropbox.Api.Async.PollError}">Thrown if /// there is an error processing the request; This will contain a <see /// cref="Dropbox.Api.Async.PollError"/>.</exception> public t.Task<Dropbox.Api.Async.PollEmptyResult> MembersRemoveJobStatusGetAsync(Dropbox.Api.Async.PollArg pollArg) { return this.Transport.SendRpcRequestAsync<Dropbox.Api.Async.PollArg, Dropbox.Api.Async.PollEmptyResult, Dropbox.Api.Async.PollError>(pollArg, "api", "/team/members/remove/job_status/get", Dropbox.Api.Async.PollArg.Encoder, Dropbox.Api.Async.PollEmptyResult.Decoder, Dropbox.Api.Async.PollError.Decoder); }
private string GetDropboxUploadPath() { return(new NameParser { IsFolderPath = true }.Convert(Dropbox.TidyUploadPath(Config.DropboxUploadPath))); }
/// <summary> /// <para>Begins an asynchronous send to the members remove job status get /// route.</para> /// </summary> /// <param name="pollArg">The request parameters.</param> /// <param name="callback">The method to be called when the asynchronous send is /// completed.</param> /// <param name="state">A user provided object that distinguished this send from other /// send requests.</param> /// <returns>An object that represents the asynchronous send request.</returns> public sys.IAsyncResult BeginMembersRemoveJobStatusGet(Dropbox.Api.Async.PollArg pollArg, sys.AsyncCallback callback, object state = null) { var task = this.MembersRemoveJobStatusGetAsync(pollArg); return enc.Util.ToApm(task, callback, state); }
private void dropboxToolStripMenuItem_Click(object sender, EventArgs e) { Dropbox dropboxForm = new Dropbox(); dropboxForm.Show(); }
private UploadResult UploadFile(string ssPath) { FileUploader fileUploader = null; switch (Program.Settings.ImageFileUploaderType) { case FileDestination.Dropbox: fileUploader = new Dropbox(Program.UploadersConfig.DropboxOAuth2Info, Program.UploadersConfig.DropboxAccountInfo) { UploadPath = NameParser.Parse(NameParserType.URL, Dropbox.TidyUploadPath(Program.UploadersConfig.DropboxUploadPath)), AutoCreateShareableLink = Program.UploadersConfig.DropboxAutoCreateShareableLink, ShareURLType = Program.UploadersConfig.DropboxURLType }; break; case FileDestination.Copy: fileUploader = new Copy(Program.UploadersConfig.CopyOAuthInfo, Program.UploadersConfig.CopyAccountInfo) { UploadPath = NameParser.Parse(NameParserType.URL, Copy.TidyUploadPath(Program.UploadersConfig.CopyUploadPath)), URLType = Program.UploadersConfig.CopyURLType }; break; case FileDestination.GoogleDrive: fileUploader = new GoogleDrive(Program.UploadersConfig.GoogleDriveOAuth2Info) { IsPublic = Program.UploadersConfig.GoogleDriveIsPublic, FolderID = Program.UploadersConfig.GoogleDriveUseFolder ? Program.UploadersConfig.GoogleDriveFolderID : null }; break; case FileDestination.RapidShare: fileUploader = new RapidShare(Program.UploadersConfig.RapidShareUsername, Program.UploadersConfig.RapidSharePassword, Program.UploadersConfig.RapidShareFolderID); break; case FileDestination.SendSpace: fileUploader = new SendSpace(APIKeys.SendSpaceKey); switch (Program.UploadersConfig.SendSpaceAccountType) { case AccountType.Anonymous: SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey); break; case AccountType.User: SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey, Program.UploadersConfig.SendSpaceUsername, Program.UploadersConfig.SendSpacePassword); break; } break; case FileDestination.Minus: fileUploader = new Minus(Program.UploadersConfig.MinusConfig, Program.UploadersConfig.MinusOAuth2Info); break; case FileDestination.Box: fileUploader = new Box(Program.UploadersConfig.BoxOAuth2Info) { FolderID = Program.UploadersConfig.BoxSelectedFolder.id, Share = Program.UploadersConfig.BoxShare }; break; case FileDestination.Gfycat: fileUploader = new GfycatUploader(); break; case FileDestination.Ge_tt: fileUploader = new Ge_tt(APIKeys.Ge_ttKey) { AccessToken = Program.UploadersConfig.Ge_ttLogin.AccessToken }; break; case FileDestination.Localhostr: fileUploader = new Hostr(Program.UploadersConfig.LocalhostrEmail, Program.UploadersConfig.LocalhostrPassword) { DirectURL = Program.UploadersConfig.LocalhostrDirectURL }; break; case FileDestination.CustomFileUploader: if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomFileUploaderSelected)) { fileUploader = new CustomFileUploader(Program.UploadersConfig.CustomUploadersList[Program.UploadersConfig.CustomFileUploaderSelected]); } break; case FileDestination.FTP: FTPAccount account = Program.UploadersConfig.FTPAccountList.ReturnIfValidIndex(Program.UploadersConfig.FTPSelectedImage); if (account != null) { if (account.Protocol == FTPProtocol.FTP || account.Protocol == FTPProtocol.FTPS) { fileUploader = new FTP(account); } else if (account.Protocol == FTPProtocol.SFTP) { fileUploader = new SFTP(account); } } break; case FileDestination.SharedFolder: int idLocalhost = Program.UploadersConfig.LocalhostSelectedImages; if (Program.UploadersConfig.LocalhostAccountList.IsValidIndex(idLocalhost)) { fileUploader = new SharedFolderUploader(Program.UploadersConfig.LocalhostAccountList[idLocalhost]); } break; case FileDestination.Email: using (EmailForm emailForm = new EmailForm(Program.UploadersConfig.EmailRememberLastTo ? Program.UploadersConfig.EmailLastTo : string.Empty, Program.UploadersConfig.EmailDefaultSubject, Program.UploadersConfig.EmailDefaultBody)) { emailForm.Icon = ShareXResources.Icon; if (emailForm.ShowDialog() == DialogResult.OK) { if (Program.UploadersConfig.EmailRememberLastTo) { Program.UploadersConfig.EmailLastTo = emailForm.ToEmail; } fileUploader = new Email { SmtpServer = Program.UploadersConfig.EmailSmtpServer, SmtpPort = Program.UploadersConfig.EmailSmtpPort, FromEmail = Program.UploadersConfig.EmailFrom, Password = Program.UploadersConfig.EmailPassword, ToEmail = emailForm.ToEmail, Subject = emailForm.Subject, Body = emailForm.Body }; } } break; case FileDestination.Jira: fileUploader = new Jira(Program.UploadersConfig.JiraHost, Program.UploadersConfig.JiraOAuthInfo, Program.UploadersConfig.JiraIssuePrefix); break; case FileDestination.Mega: fileUploader = new Mega(Program.UploadersConfig.MegaAuthInfos, Program.UploadersConfig.MegaParentNodeId); break; case FileDestination.AmazonS3: fileUploader = new AmazonS3(Program.UploadersConfig.AmazonS3Settings); break; case FileDestination.OwnCloud: fileUploader = new OwnCloud(Program.UploadersConfig.OwnCloudHost, Program.UploadersConfig.OwnCloudUsername, Program.UploadersConfig.OwnCloudPassword) { Path = Program.UploadersConfig.OwnCloudPath, CreateShare = Program.UploadersConfig.OwnCloudCreateShare, DirectLink = Program.UploadersConfig.OwnCloudDirectLink, IgnoreInvalidCert = Program.UploadersConfig.OwnCloudIgnoreInvalidCert }; break; case FileDestination.Pushbullet: fileUploader = new Pushbullet(Program.UploadersConfig.PushbulletSettings); break; case FileDestination.MediaCrush: fileUploader = new MediaCrushUploader() { DirectLink = Program.UploadersConfig.MediaCrushDirectLink }; break; case FileDestination.MediaFire: fileUploader = new MediaFire(APIKeys.MediaFireAppId, APIKeys.MediaFireApiKey, Program.UploadersConfig.MediaFireUsername, Program.UploadersConfig.MediaFirePassword) { UploadPath = NameParser.Parse(NameParserType.URL, Program.UploadersConfig.MediaFirePath), UseLongLink = Program.UploadersConfig.MediaFireUseLongLink }; break; case FileDestination.Pomf: fileUploader = new Pomf(); break; } if (fileUploader != null) { ReportProgress(ProgressType.UPDATE_STATUSBAR_DEBUG, string.Format("Uploading {0}.", Path.GetFileName(ssPath))); return(fileUploader.Upload(ssPath)); } return(null); }
public UploadResult UploadFile(Stream stream, string fileName) { FileUploader fileUploader = null; FileDestination fileDestination; switch (Info.DataType) { case EDataType.Image: fileDestination = Info.TaskSettings.ImageFileDestination; break; case EDataType.Text: fileDestination = Info.TaskSettings.TextFileDestination; break; default: case EDataType.File: fileDestination = Info.TaskSettings.FileDestination; break; } switch (fileDestination) { case FileDestination.Dropbox: NameParser parser = new NameParser(NameParserType.URL); string uploadPath = parser.Parse(Dropbox.TidyUploadPath(Program.UploadersConfig.DropboxUploadPath)); fileUploader = new Dropbox(Program.UploadersConfig.DropboxOAuthInfo, Program.UploadersConfig.DropboxAccountInfo) { UploadPath = uploadPath, AutoCreateShareableLink = Program.UploadersConfig.DropboxAutoCreateShareableLink, ShareURLType = Program.UploadersConfig.DropboxURLType }; break; case FileDestination.GoogleDrive: fileUploader = new GoogleDrive(Program.UploadersConfig.GoogleDriveOAuth2Info) { IsPublic = Program.UploadersConfig.GoogleDriveIsPublic }; break; case FileDestination.RapidShare: fileUploader = new RapidShare(Program.UploadersConfig.RapidShareUsername, Program.UploadersConfig.RapidSharePassword, Program.UploadersConfig.RapidShareFolderID); break; case FileDestination.SendSpace: fileUploader = new SendSpace(APIKeys.SendSpaceKey); switch (Program.UploadersConfig.SendSpaceAccountType) { case AccountType.Anonymous: SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey); break; case AccountType.User: SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey, Program.UploadersConfig.SendSpaceUsername, Program.UploadersConfig.SendSpacePassword); break; } break; case FileDestination.Minus: fileUploader = new Minus(Program.UploadersConfig.MinusConfig, Program.UploadersConfig.MinusOAuth2Info); break; case FileDestination.Box: fileUploader = new Box(Program.UploadersConfig.BoxOAuth2Info) { FolderID = Program.UploadersConfig.BoxSelectedFolder.id, Share = Program.UploadersConfig.BoxShare }; break; case FileDestination.Ge_tt: if (Program.UploadersConfig.IsActive(FileDestination.Ge_tt)) { fileUploader = new Ge_tt(APIKeys.Ge_ttKey) { AccessToken = Program.UploadersConfig.Ge_ttLogin.AccessToken }; } break; case FileDestination.Localhostr: fileUploader = new Hostr(Program.UploadersConfig.LocalhostrEmail, Program.UploadersConfig.LocalhostrPassword) { DirectURL = Program.UploadersConfig.LocalhostrDirectURL }; break; case FileDestination.CustomFileUploader: if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomFileUploaderSelected)) { fileUploader = new CustomFileUploader(Program.UploadersConfig.CustomUploadersList[Program.UploadersConfig.CustomFileUploaderSelected]); } break; case FileDestination.FTP: int index = Info.TaskSettings.OverrideFTP ? Info.TaskSettings.FTPIndex.BetweenOrDefault(0, Program.UploadersConfig.FTPAccountList.Count - 1) : Program.UploadersConfig.GetFTPIndex(Info.DataType); FTPAccount account = Program.UploadersConfig.FTPAccountList.ReturnIfValidIndex(index); if (account != null) { if (account.Protocol == FTPProtocol.SFTP) { fileUploader = new SFTP(account); } else { fileUploader = new FTPUploader(account); } } break; case FileDestination.SharedFolder: int idLocalhost = Program.UploadersConfig.GetLocalhostIndex(Info.DataType); if (Program.UploadersConfig.LocalhostAccountList.IsValidIndex(idLocalhost)) { fileUploader = new SharedFolderUploader(Program.UploadersConfig.LocalhostAccountList[idLocalhost]); } break; case FileDestination.Email: using (EmailForm emailForm = new EmailForm(Program.UploadersConfig.EmailRememberLastTo ? Program.UploadersConfig.EmailLastTo : string.Empty, Program.UploadersConfig.EmailDefaultSubject, Program.UploadersConfig.EmailDefaultBody)) { emailForm.Icon = ShareXResources.Icon; if (emailForm.ShowDialog() == DialogResult.OK) { if (Program.UploadersConfig.EmailRememberLastTo) { Program.UploadersConfig.EmailLastTo = emailForm.ToEmail; } fileUploader = new Email { SmtpServer = Program.UploadersConfig.EmailSmtpServer, SmtpPort = Program.UploadersConfig.EmailSmtpPort, FromEmail = Program.UploadersConfig.EmailFrom, Password = Program.UploadersConfig.EmailPassword, ToEmail = emailForm.ToEmail, Subject = emailForm.Subject, Body = emailForm.Body }; } else { IsStopped = true; } } break; case FileDestination.Jira: fileUploader = new Jira(Program.UploadersConfig.JiraHost, Program.UploadersConfig.JiraOAuthInfo, Program.UploadersConfig.JiraIssuePrefix); break; case FileDestination.Mega: fileUploader = new Mega(Program.UploadersConfig.MegaAuthInfos, Program.UploadersConfig.MegaParentNodeId); break; case FileDestination.AmazonS3: fileUploader = new AmazonS3(Program.UploadersConfig.AmazonS3Settings); break; case FileDestination.Pushbullet: fileUploader = new Pushbullet(Program.UploadersConfig.PushbulletSettings); break; } if (fileUploader != null) { PrepareUploader(fileUploader); return(fileUploader.Upload(stream, fileName)); } return(null); }
/// <summary> /// <para>Once an async_job_id is returned from <see /// cref="Dropbox.Api.Team.Routes.TeamRoutes.MembersAddAsync" /> , use this to poll the /// status of the asynchronous request.</para> /// <para>Permission : Team member management</para> /// </summary> /// <param name="pollArg">The request parameters</param> /// <returns>The task that represents the asynchronous send operation. The TResult /// parameter contains the response from the server.</returns> /// <exception cref="Dropbox.Api.ApiException{Dropbox.Api.Async.PollError}">Thrown if /// there is an error processing the request; This will contain a <see /// cref="Dropbox.Api.Async.PollError"/>.</exception> public t.Task<MembersAddJobStatus> MembersAddJobStatusGetAsync(Dropbox.Api.Async.PollArg pollArg) { return this.Transport.SendRpcRequestAsync<Dropbox.Api.Async.PollArg, MembersAddJobStatus, Dropbox.Api.Async.PollError>(pollArg, "api", "/team/members/add/job_status/get", Dropbox.Api.Async.PollArg.Encoder, Dropbox.Api.Team.MembersAddJobStatus.Decoder, Dropbox.Api.Async.PollError.Decoder); }