void Save_Click(object sender, EventArgs e) { Settings.Instance.OutlookAutoLogonProfileName = outlookAutoLogonTextBox.Text; Settings.Instance.SetOutlookAutoLogonProfilePassword(outlookAutoLogonPwdTextBox.Text); XMLManager.export(Settings.Instance, FILENAME); }
public bool InitCalendarService(string user) { try { // obtain the user's credentials Google.Apis.Auth.OAuth2.UserCredential user_credential = Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.AuthorizeAsync( new Google.Apis.Auth.OAuth2.ClientSecrets { ClientId = "857287834886-tau9nuakoamjctkm3plbqeojjrlmn140.apps.googleusercontent.com", ClientSecret = "Gb5q1srU74At1erFyLQBKxXm" }, new [] { Google.Apis.Calendar.v3.CalendarService.Scope.Calendar }, user, System.Threading.CancellationToken.None).Result; if (user_credential != null) { // init the calendar service service = new Google.Apis.Calendar.v3.CalendarService( new Google.Apis.Services.BaseClientService.Initializer() { HttpClientInitializer = user_credential, ApplicationName = "GoogleOutlookCalendarSync" }); // save the refresh token // this is not needed anymore, as the optional data store is a file store located // at Google.Apis.Auth under the user's Environment.SpecialFolder.ApplicationData // keep this for backwards compatibility, as it may be needed in the future Settings.Instance.RefreshToken = user_credential.Token.RefreshToken; // export the settings to keep backwards compatibility XMLManager.export(Settings.Instance, MainForm.FILENAME); } } catch (System.Exception) { // something went very wrong so the service is dead service = null; } // indicate if the service was initialized return(service != null ? true : false); }
void SyncNow_Click(object sender, EventArgs e) { // update the property key value before doing the sync UpdateEventPropertyKey(); bSyncNow.Enabled = false; lNextSync.Text = "Next scheduled sync:\n In progress..."; LogBox.Clear(); DateTime SyncStarted = DateTime.Now; logboxout("Sync started at " + SyncStarted.ToString()); logboxout("--------------------------------------------------"); Boolean syncOk = synchronize(); logboxout("--------------------------------------------------"); logboxout(syncOk ? "Sync finished with success!" : "Sync finished with errors!"); if (syncOk) { lastSyncDate = SyncStarted; Settings.Instance.LastSyncDate = lastSyncDate; XMLManager.export(Settings.Instance, FILENAME); lLastSync.Text = "Last succeded synchro:\n " + SyncStarted.ToLongDateString() + " - " + SyncStarted.ToLongTimeString(); setNextSync(getResyncInterval()); } else { setNextSync(5); } if (!Settings.Instance.OutlookKeepOpenAfterSync) { // close the outlook calendar instance so not to always be logged in OutlookCalendar.Instance.Release(); } bSyncNow.Enabled = true; }
private static IAuthorizationState GetAuthentication(NativeApplicationClient arg) { // Get the auth URL: IAuthorizationState state = new AuthorizationState(new[] { CalendarService.Scopes.Calendar.GetStringValue() }); state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl); state.RefreshToken = Settings.Instance.RefreshToken; Uri authUri = arg.RequestUserAuthorization(state); IAuthorizationState result = null; if (state.RefreshToken == "") { // Request authorization from the user (by opening a browser window): Process.Start(authUri.ToString()); EnterAuthorizationCode eac = new EnterAuthorizationCode(); if (eac.ShowDialog() == DialogResult.OK) { // Retrieve the access/refresh tokens by using the authorization code: result = arg.ProcessUserAuthorization(eac.authcode, state); //save the refresh token for future use Settings.Instance.RefreshToken = result.RefreshToken; XMLManager.export(Settings.Instance, MainForm.FILENAME); return(result); } else { return(null); } } else { arg.RefreshToken(state, null); result = state; return(result); } }
private void Save_Click(object sender, EventArgs e) { XMLManager.export(Settings.Instance, FILENAME); }
public MainForm() { InitializeComponent(); label4.Text = label4.Text.Replace("{version}", VERSION); Instance = this; //set system proxy //WebProxy wp = (WebProxy)WebRequest.DefaultWebProxy; //wp.UseDefaultCredentials = true; //System.Net.WebRequest.DefaultWebProxy = wp; //load settings/create settings file if (File.Exists(FILENAME)) { Settings.Instance = XMLManager.import <Settings>(FILENAME); } else { XMLManager.export(Settings.Instance, FILENAME); } //update GUI from Settings tbDaysInThePast.Text = Settings.Instance.DaysInThePast.ToString(); tbDaysInTheFuture.Text = Settings.Instance.DaysInTheFuture.ToString(); tbMinuteOffsets.Text = Settings.Instance.MinuteOffsets; cbCalendars.Items.Add(Settings.Instance.UseGoogleCalendar); cbCalendars.SelectedIndex = 0; cbSyncEveryHour.Checked = Settings.Instance.SyncEveryHour; cbShowBubbleTooltips.Checked = Settings.Instance.ShowBubbleTooltipWhenSyncing; cbStartInTray.Checked = Settings.Instance.StartInTray; cbStartWithWindows.Checked = Settings.Instance.StartWithWindows; cbMinimizeToTray.Checked = Settings.Instance.MinimizeToTray; cbAddDescription.Checked = Settings.Instance.AddDescription; cbAddAttendees.Checked = Settings.Instance.AddAttendeesToDescription; cbAddReminders.Checked = Settings.Instance.AddReminders; cbCreateFiles.Checked = Settings.Instance.CreateTextFiles; txtEWSPass.Text = Settings.Instance.ExchagePassword; txtEWSUser.Text = Settings.Instance.ExchageUser; txtEWSServerURL.Text = Settings.Instance.ExchageServerAddress; chkUseEWS.Checked = Settings.Instance.UseExchange; //Start in tray? if (cbStartInTray.Checked) { this.WindowState = FormWindowState.Minimized; this.ShowInTaskbar = false; notifyIcon1.Visible = true; this.Hide(); } //set up timer (every 30s) for checking the minute offsets _ogstimer = new Timer(); _ogstimer.Interval = 30000; _ogstimer.Tick += new EventHandler(ogstimer_Tick); _ogstimer.Start(); _oldtime = DateTime.Now; //set up tooltips for some controls ToolTip toolTip1 = new ToolTip(); toolTip1.AutoPopDelay = 10000; toolTip1.InitialDelay = 500; toolTip1.ReshowDelay = 200; toolTip1.ShowAlways = true; toolTip1.SetToolTip(cbCalendars, "The Google Calendar to synchonize with."); toolTip1.SetToolTip(tbMinuteOffsets, "One ore more Minute Offsets at which the sync is automatically started each hour. \n" + "Separate by comma (e.g. 5,15,25)."); toolTip1.SetToolTip(cbAddAttendees, "While Outlook has fields for Organizer, RequiredAttendees and OptionalAttendees, Google has not.\n" + "If checked, this data is added at the end of the description as text."); toolTip1.SetToolTip(cbAddReminders, "If checked, the reminder set in outlook will be carried over to the Google Calendar entry (as a popup reminder)."); toolTip1.SetToolTip(cbCreateFiles, "If checked, all entries found in Outlook/Google and identified for creation/deletion will be exported \n" + "to 4 separate text files in the application's directory (named \"export_*.txt\"). \n" + "Only for debug/diagnostic purposes."); toolTip1.SetToolTip(cbAddDescription, "The description may contain email addresses, which Outlook may complain about (PopUp-Message: \"Allow Access?\" etc.). \n" + "Turning this off allows OutlookGoogleSync to run without intervention in this case."); CreateOfficeCalendar(); }
public MainForm() { if (System.IO.Directory.Exists(LOCAL_APP_DATA) == false) { System.IO.Directory.CreateDirectory(LOCAL_APP_DATA); } InitializeComponent(); label4.Text = label4.Text.Replace("{version}", VERSION); Instance = this; //set system proxy WebProxy wp = new WebProxy(); wp.UseDefaultCredentials = true; System.Net.WebRequest.DefaultWebProxy = wp; //load settings/create settings file if (File.Exists(FILENAME)) { Settings.Instance = XMLManager.import <Settings>(FILENAME); } else { XMLManager.export(Settings.Instance, FILENAME); } //create the timer for the autosynchro ogstimer = new Timer(); ogstimer.Tick += new EventHandler(ogstimer_Tick); //update GUI from Settings tbDaysInThePast.Text = Settings.Instance.DaysInThePast.ToString(); tbDaysInTheFuture.Text = Settings.Instance.DaysInTheFuture.ToString(); tbMinuteOffsets.Text = Settings.Instance.MinuteOffsets; lastSyncDate = Settings.Instance.LastSyncDate; cbCalendars.Items.Add(Settings.Instance.UseGoogleCalendar); cbCalendars.SelectedIndex = 0; cbSyncEveryHour.Checked = Settings.Instance.SyncEveryHour; cbShowBubbleTooltips.Checked = Settings.Instance.ShowBubbleTooltipWhenSyncing; cbStartInTray.Checked = Settings.Instance.StartInTray; cbMinimizeToTray.Checked = Settings.Instance.MinimizeToTray; cbAddDescription.Checked = Settings.Instance.AddDescription; cbAddAttendees.Checked = Settings.Instance.AddAttendeesToDescription; cbAddReminders.Checked = Settings.Instance.AddReminders; cbCreateFiles.Checked = Settings.Instance.CreateTextFiles; outlookAutoLogonCheckBox.Checked = Settings.Instance.OutlookAutoLogonEnabled; outlookKeepOpenAfterSync.Checked = Settings.Instance.OutlookKeepOpenAfterSync; outlookAutoLogonTextBox.Text = Settings.Instance.OutlookAutoLogonProfileName; outlookAutoLogonPwdTextBox.Text = Settings.Instance.GetOutlookAutoLogonProfilePassword(); // init the calendar service if the user is populated if (Settings.Instance.UseGoogleCalendar.User != "") { if (!GoogleCalendar.Instance.InitCalendarService(Settings.Instance.UseGoogleCalendar.User)) { cbCalendars.Items.Clear(); logboxout("Unable to initialize Google calendar service for the following Google user: "******"The Google Calendar to synchonize with."); toolTip1.SetToolTip(tbMinuteOffsets, "One ore more Minute Offsets at which the sync is automatically started each hour. \n" + "Separate by comma (e.g. 5,15,25)."); toolTip1.SetToolTip(cbAddAttendees, "While Outlook has fields for Organizer, RequiredAttendees and OptionalAttendees, Google has not.\n" + "If checked, this data is added at the end of the description as text."); toolTip1.SetToolTip(cbAddReminders, "If checked, the reminder set in outlook will be carried over to the Google Calendar entry (as a popup reminder)."); toolTip1.SetToolTip(cbCreateFiles, "If checked, all entries found in Outlook/Google and identified for creation/deletion will be exported \n" + "to 4 separate text files in the application's directory (named \"export_*.txt\"). \n" + "Only for debug/diagnostic purposes."); toolTip1.SetToolTip(cbAddDescription, "The description may contain email addresses, which Outlook may complain about (PopUp-Message: \"Allow Access?\" etc.). \n" + "Turning this off allows OutlookGoogleSync to run without intervention in this case."); //Refresh synchronizations (last and next) lLastSync.Text = "Last succeded synchro:\n " + lastSyncDate.ToLongDateString() + " - " + lastSyncDate.ToLongTimeString(); setNextSync(getResyncInterval()); }