Esempio n. 1
0
        // TODO: this is displaying a Form which is not so good for unit testing or anything
        public Boolean Login()
        {
            try
            {
                //Check prekeyring.xml to see if the Dropbox credential exists.
                SecuruStik.DB.AccessToken at = PreKeyring.AccessToken;
                //If not,pop up a login window asking the user to enter his/her account && password
                if (at == null)
                {
                    this.client = new DropNet.DropNetClient(AppSetting.apiKey, AppSetting.appSecret);
                    this.client.GetToken();

                    //Ask user to enter DropBox account and password
                    SecuruStikMessageQueue.SendMessage_Splash_Hiden();
                    AuthorizeForm af = new AuthorizeForm(this.AuthorizeUrl);
                    af.ShowDialog();

                    if (af.DialogResult == DialogResult.OK)
                    {
                        return(this.GetAccessToken());
                    }
                    else if (af.DialogResult == DialogResult.Cancel)
                    {
                        return(false);
                    }
                }
                else
                {
                    this.client = new DropNet.DropNetClient(
                        AppSetting.apiKey,
                        AppSetting.appSecret,
                        at.UserToken, at.UserSecret, null);
                }
            } catch (System.Exception ex)
            {
                throw new SecuruStikException(
                          SecuruStikExceptionType.DropBoxControl_Login,
                          "Failed to Login the dropbox",
                          ex);
            }
            return(true);
        }
        // TODO: this is displaying a Form which is not so good for unit testing or anything
        public Boolean Login()
        {
            try
            {
                //Check prekeyring.xml to see if the Dropbox credential exists.
                SecuruStik.DB.AccessToken at = PreKeyring.AccessToken;
                //If not,pop up a login window asking the user to enter his/her account && password
                if ( at == null )
                {
                    this.client = new DropNet.DropNetClient( AppSetting.apiKey , AppSetting.appSecret );
                    this.client.GetToken();

                    //Ask user to enter DropBox account and password
                    SecuruStikMessageQueue.SendMessage_Splash_Hiden();
                    AuthorizeForm af = new AuthorizeForm( this.AuthorizeUrl );
                    af.ShowDialog();

                    if ( af.DialogResult == DialogResult.OK )
                    {
                        return this.GetAccessToken();
                    }
                    else if ( af.DialogResult == DialogResult.Cancel )
                        return false;
                }
                else
                {
                    this.client = new DropNet.DropNetClient(
                                AppSetting.apiKey ,
                                AppSetting.appSecret ,
                                at.UserToken , at.UserSecret , null );
                }
            } catch ( System.Exception ex )
            {
                throw new SecuruStikException(
                     SecuruStikExceptionType.DropBoxControl_Login ,
                     "Failed to Login the dropbox" ,
                     ex );
            }
            return true;
        }