/// <summary> /// Cleans up the model for disposing /// </summary> public void Dispose() { try { GoogleEmailUploaderTrace.EnteringMethod( "GoogleEmailUploaderModel.Dispose"); if (this.modelState == ModelState.Initialized) { this.gaiaAuthenticator = null; } else if (this.modelState == ModelState.SignedIn) { this.emailId = null; this.password = null; this.lkgStatePersistor.SaveLKGState(this); this.lkgStatePersistor = null; this.flatStoreModelList = null; this.flatFolderModelList = null; this.DisposeClientModels(); } else if (this.modelState == ModelState.Uploading || this.modelState == ModelState.UploadingPause) { this.emailId = null; this.password = null; this.lkgStatePersistor = null; this.flatStoreModelList = null; this.flatFolderModelList = null; this.mailUploader = null; this.contactIterator.Dispose(); this.mailIterator.Dispose(); this.contactIterator = null; this.mailIterator = null; if (this.pauseTimer != null) { this.pauseTimer.Dispose(); this.pauseTimer = null; } this.DisposeClientModels(); } } finally { GoogleEmailUploaderTrace.ExitingMethod( "GoogleEmailUploaderModel.Dispose"); } }
void TransitionToInitializedState() { this.gaiaAuthenticator = new GoogleAuthenticator(this.HttpFactory, AccountType.GoogleOrHosted, this.ApplicationName); this.emailId = null; this.password = null; this.lkgStatePersistor = null; this.flatStoreModelList = null; this.flatFolderModelList = null; this.mailUploader = null; this.contactIterator = null; this.mailIterator = null; this.pauseTimer = null; this.modelState = ModelState.Initialized; }
void TransitionToSignedInState(string emailId, string password) { Debug.Assert(this.modelState == ModelState.Initialized); this.emailId = emailId; this.password = password; if (this.LoadingClientsEvent != null) { this.LoadingClientsEvent(); } this.gaiaAuthenticator = null; this.LoadingClientsEvent = null; this.lkgStatePersistor = new LKGStatePersistor(emailId); this.clientModels = new ArrayList(); this.LoadClients(); this.modelState = ModelState.SignedIn; this.lkgStatePersistor.LoadLKGState(this); this.BuildModelFlatList(); this.mailUploader = new MailUploader(this.HttpFactory, this.emailId, this.password, this.ApplicationName, this); }
internal MailUploader(IHttpFactory httpFactory, string emailId, string password, string applicationName, GoogleEmailUploaderModel googleEmailUploaderModel) { this.HttpFactory = httpFactory; this.EmailId = emailId; this.Password = password; GoogleAuthenticator authenticator = new GoogleAuthenticator(httpFactory, AccountType.GoogleOrHosted, applicationName); AuthenticationResponse resp = authenticator.AuthenticateForService(this.EmailId, this.Password, "apps"); this.MailAuthenticationToken = resp.AuthToken; resp = authenticator.AuthenticateForService(this.EmailId, this.Password, "cp"); this.ContactAuthenticationToken = resp.AuthToken; this.GoogleEmailUploaderModel = googleEmailUploaderModel; string[] splits = emailId.Split('@'); this.UserName = splits[0]; this.DomainName = splits[1]; this.MailBatch = new MailBatch(googleEmailUploaderModel); this.ContactEntry = new ContactEntry(googleEmailUploaderModel); this.PauseEvent = new ManualResetEvent(true); this.batchMailUploadUrl = string.Format( GoogleEmailUploaderConfig.EmailMigrationUrl, this.DomainName, this.UserName); this.batchContactUploadUrl = string.Format( MailUploader.ContactMigrationURLTemplate, this.EmailId); this.ApplicationName = applicationName; }