コード例 #1
0
ファイル: RtmBackend.cs プロジェクト: antoniusriha/Tasque
		public void Initialize (IPreferences preferences)
		{
			if (preferences == null)
				throw new ArgumentNullException ("preferences");
			this.preferences = preferences;

			// *************************************
			// AUTHENTICATION to Remember The Milk
			// *************************************
			string authToken = preferences.Get (PreferencesKeys.AuthTokenKey);
			if (authToken != null) {
				Logger.Debug ("Found AuthToken, checking credentials...");
				try {
					Rtm = new RtmNet.Rtm (ApiKey, SharedSecret, authToken);
					rtmAuth = Rtm.AuthCheckToken (authToken);
					Timeline = Rtm.TimelineCreate ();
					Logger.Debug ("RTM Auth Token is valid!");
					Logger.Debug ("Setting configured status to true");
					IsConfigured = true;
				} catch (RtmNet.RtmApiException e) {
					preferences.Set (PreferencesKeys.AuthTokenKey, null);
					preferences.Set (PreferencesKeys.UserIdKey, null);
					preferences.Set (PreferencesKeys.UserNameKey, null);
					Rtm = null;
					rtmAuth = null;
					Logger.Error ("Exception authenticating, reverting "
					              + e.Message);
				} catch (RtmNet.ResponseXmlException e) {
					Rtm = null;
					rtmAuth = null;
					Logger.Error ("Cannot parse RTM response. " +
						"Maybe the service is down. " + e.Message);
				} catch (RtmNet.RtmWebException e) {
					Rtm = null;
					rtmAuth = null;
					Logger.Error ("Not connected to RTM, maybe proxy: #{0}",
					              e.Message);
				} catch (System.Net.WebException e) {
					Rtm = null;
					rtmAuth = null;
					Logger.Error ("Problem connecting to internet: #{0}",
					              e.Message);
				}
			}

			if (Rtm == null) {
				Rtm = new RtmNet.Rtm (ApiKey, SharedSecret);
				return;
			}

			FinishInitialization ();
		}
コード例 #2
0
ファイル: RtmBackend.cs プロジェクト: teotikalki/tasque
        public void FinishedAuth()
        {
            rtmAuth = Rtm.AuthGetToken(frob);
            if (rtmAuth != null)
            {
                preferences.Set(PreferencesKeys.AuthTokenKey, rtmAuth.Token);
                if (rtmAuth.User != null)
                {
                    preferences.Set(PreferencesKeys.UserNameKey,
                                    rtmAuth.User.Username);
                    preferences.Set(PreferencesKeys.UserIdKey,
                                    rtmAuth.User.UserId);
                }
            }

            var authToken = preferences.Get(PreferencesKeys.AuthTokenKey);

            if (authToken != null)
            {
                Logger.Debug("Found AuthToken, checking credentials...");
                try {
                    Rtm      = new RtmNet.Rtm(ApiKey, SharedSecret, authToken);
                    rtmAuth  = Rtm.AuthCheckToken(authToken);
                    Timeline = Rtm.TimelineCreate();
                    Logger.Debug("RTM Auth Token is valid!");
                    Logger.Debug("Setting configured status to true");
                    IsConfigured = true;
                    FinishInitialization();
                } catch (Exception e) {
                    Rtm     = null;
                    rtmAuth = null;
                    Logger.Error("Exception authenticating, reverting"
                                 + e.Message);
                }
            }
        }
コード例 #3
0
ファイル: RtmBackend.cs プロジェクト: GNOME/tasque
		public void FinishedAuth ()
		{
			rtmAuth = Rtm.AuthGetToken (frob);
			if (rtmAuth != null) {
				preferences.Set (PreferencesKeys.AuthTokenKey, rtmAuth.Token);
				if (rtmAuth.User != null) {
					preferences.Set (PreferencesKeys.UserNameKey,
					                 rtmAuth.User.Username);
					preferences.Set (PreferencesKeys.UserIdKey,
					                 rtmAuth.User.UserId);
				}
			}
			
			var authToken = preferences.Get (PreferencesKeys.AuthTokenKey);
			if (authToken != null) {
				Logger.Debug ("Found AuthToken, checking credentials...");
				try {
					Rtm = new RtmNet.Rtm (ApiKey, SharedSecret, authToken);
					rtmAuth = Rtm.AuthCheckToken (authToken);
					Timeline = Rtm.TimelineCreate ();
					Logger.Debug ("RTM Auth Token is valid!");
					Logger.Debug ("Setting configured status to true");
					IsConfigured = true;
					FinishInitialization ();
				} catch (Exception e) {
					Rtm = null;
					rtmAuth = null;				
					Logger.Error ("Exception authenticating, reverting"
					              + e.Message);
				}
			}
		}
コード例 #4
0
ファイル: RtmBackend.cs プロジェクト: teotikalki/tasque
        public void Initialize(IPreferences preferences)
        {
            if (preferences == null)
            {
                throw new ArgumentNullException("preferences");
            }
            this.preferences = preferences;

            // *************************************
            // AUTHENTICATION to Remember The Milk
            // *************************************
            string authToken = preferences.Get(PreferencesKeys.AuthTokenKey);

            if (authToken != null)
            {
                Logger.Debug("Found AuthToken, checking credentials...");
                try {
                    Rtm      = new RtmNet.Rtm(ApiKey, SharedSecret, authToken);
                    rtmAuth  = Rtm.AuthCheckToken(authToken);
                    Timeline = Rtm.TimelineCreate();
                    Logger.Debug("RTM Auth Token is valid!");
                    Logger.Debug("Setting configured status to true");
                    IsConfigured = true;
                } catch (RtmNet.RtmApiException e) {
                    preferences.Set(PreferencesKeys.AuthTokenKey, null);
                    preferences.Set(PreferencesKeys.UserIdKey, null);
                    preferences.Set(PreferencesKeys.UserNameKey, null);
                    Rtm     = null;
                    rtmAuth = null;
                    Logger.Error("Exception authenticating, reverting "
                                 + e.Message);
                } catch (RtmNet.ResponseXmlException e) {
                    Rtm     = null;
                    rtmAuth = null;
                    Logger.Error("Cannot parse RTM response. " +
                                 "Maybe the service is down. " + e.Message);
                } catch (RtmNet.RtmWebException e) {
                    Rtm     = null;
                    rtmAuth = null;
                    Logger.Error("Not connected to RTM, maybe proxy: #{0}",
                                 e.Message);
                } catch (System.Net.WebException e) {
                    Rtm     = null;
                    rtmAuth = null;
                    Logger.Error("Problem connecting to internet: #{0}",
                                 e.Message);
                }
            }

            if (Rtm == null)
            {
                Rtm = new RtmNet.Rtm(ApiKey, SharedSecret);
                if (NeedsConfiguration != null)
                {
                    NeedsConfiguration(this, EventArgs.Empty);
                }
                return;
            }

            FinishInitialization();
        }