private void TryLogin(TwitterNet twitter)
 {
     try
     {
         // Schedule the update function in the UI thread.
         LayoutRoot.Dispatcher.BeginInvoke(
             System.Windows.Threading.DispatcherPriority.Normal,
             new PostLoginDelegate(UpdatePostLoginInterface), twitter.Login());
     }
     catch (WebException ex)
     {
         logger.Error("There was a problem logging in Twitter.");
         MessageBox.Show("There was a problem logging in to Twitter. " + ex.Message);
     }
     catch (RateLimitException ex)
     {
         logger.Error("There was a rate limit exception.");
         MessageBox.Show(ex.Message);
     }
     catch (ProxyAuthenticationRequiredException ex)
     {
         logger.Error("Incorrect proxy configuration.");
         MessageBox.Show("Proxy server is configured incorrectly.  Please correct the settings on the Options menu.");
     }
 }
Exemple #2
0
        public Followers()
        {
            InitializeComponent();

            TwitterNet twitter = new TwitterNet("WittyTest", TwitterNet.ToSecureString("WittyTest"));
            FriendsListBox.ItemsSource = twitter.GetFriends();
        }
Exemple #3
0
        public void Init()
        {
            username = "******";
            password = TwitterNet.ToSecureString("WittyTest");
            userId = 14203624; // WittyTest's Twitter id

            TwitterNet twitter = new TwitterNet(username, password);
            testUser = twitter.Login();
        }
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            // Jason Follas: Reworked Web Proxy - don't need to explicitly pass into TwitterNet ctor
            //TwitterNet twitter = new TwitterNet(UsernameTextBox.Text, TwitterNet.ToSecureString(PasswordTextBox.Password), WebProxyHelper.GetConfiguredWebProxy());
            TwitterNet twitter = new TwitterNet(UsernameTextBox.Text, TwitterNet.ToSecureString(PasswordTextBox.Password)); //, WebProxyHelper.GetConfiguredWebProxy());

            // Jason Follas: Twitter proxy servers, anyone?  (Network Nazis who block twitter.com annoy me)
            twitter.TwitterServerUrl = AppSettings.TwitterHost;

            // Attempt login in a new thread
            LoginButton.Dispatcher.BeginInvoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new LoginDelegate(TryLogin), twitter);
        }
 public void updateLogins(String user, String password, String domain)
 {
     if (domain != null && user != null && password != null)
     {
         SecureString spassword = getPasswordAsSecureString(password);
         twitter = new TwitterNet(user, spassword);
         twitter.TwitterServerUrl = "https://" + domain + "/api/twitter/";
         twitter.ClientName = "SharePoint";
     }
     else
     {
         twitter = null;
     }
 }
Exemple #6
0
        public Options()
        {
            this.InitializeComponent();
            AlertSelectedOnlyCheckBox.IsChecked = AppSettings.AlertSelectedOnly;
            twitter = new TwitterNet(AppSettings.Username, TwitterNet.DecryptString(AppSettings.Password));
            LayoutRoot.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new NoArgDelegate(BindFriendsDropDown));

            #region Initialize Options

            UsernameTextBox.Text = AppSettings.Username;
            PasswordTextBox.Password = AppSettings.Password;
            TwitterHostTextBox.Text = AppSettings.TwitterHost;

            RefreshComboBox.Items.Add(1);
            RefreshComboBox.Items.Add(2);
            RefreshComboBox.Items.Add(5);
            RefreshComboBox.Items.Add(10);
            RefreshComboBox.Items.Add(15);
            RefreshComboBox.Items.Add(20);
            RefreshComboBox.Items.Add(30);
            RefreshComboBox.Items.Add(60);

            if (!string.IsNullOrEmpty(AppSettings.RefreshInterval))
            {
                Double refreshInterval = Double.Parse(AppSettings.RefreshInterval);
                if (refreshInterval < 1) refreshInterval = 1; //Previously the options screen allowed setting to 0
                RefreshComboBox.Text = refreshInterval.ToString();
            }

            RetweetComboBox.Items.Add("RT");
            RetweetComboBox.Items.Add("Retweet");
            RetweetComboBox.Items.Add("\u267A");
            RetweetComboBox.Items.Add("\u00BB");

            if (!string.IsNullOrEmpty(AppSettings.RetweetPrefix))
                RetweetComboBox.Text = AppSettings.RetweetPrefix;

            ReplyComboBox.Items.Add("r");
            ReplyComboBox.Items.Add("-");
            ReplyComboBox.Items.Add(".");
            ReplyComboBox.Items.Add(">");
            ReplyComboBox.Items.Add("\u00BB");

            if (!string.IsNullOrEmpty(AppSettings.ReplyPrefix))
                ReplyComboBox.Text = AppSettings.ReplyPrefix;

            isInitializing = true;
            SkinsComboBox.ItemsSource = SkinsManager.GetSkins();

            // select the current skin
            if (!string.IsNullOrEmpty(AppSettings.Skin))
            {
                SkinsComboBox.SelectedItem = AppSettings.Skin;
            }

            UrlServiceComboBox.ItemsSource = Enum.GetValues(typeof(TwitterLib.ShorteningService));
            if (!string.IsNullOrEmpty(AppSettings.UrlShorteningService))
                UrlServiceComboBox.Text = AppSettings.UrlShorteningService;
            else
                UrlServiceComboBox.Text = TwitterLib.ShorteningService.TinyUrl.ToString();

            // select number of tweets to keep
            KeepLatestComboBox.Text = AppSettings.KeepLatest.ToString();
            isInitializing = false;

            AlwaysOnTopCheckBox.IsChecked = AppSettings.AlwaysOnTop;

            PlaySounds = AppSettings.PlaySounds;
            MinimizeToTray = AppSettings.MinimizeToTray;
            MinimizeOnClose = AppSettings.MinimizeOnClose;
            PersistLogin = AppSettings.PersistLogin;
            SmoothScrollingCheckBox.IsChecked = AppSettings.SmoothScrolling;
            RunAtStartupCheckBox.IsChecked = AppSettings.RunAtStartup;

            UseProxyCheckBox.IsChecked = AppSettings.UseProxy;
            ProxyServerTextBox.Text = AppSettings.ProxyServer;
            ProxyPortTextBox.Text = AppSettings.ProxyPort.ToString();
            ProxyUsernameTextBox.Text = AppSettings.ProxyUsername;
            FilterRegex.Text = AppSettings.FilterRegex;
            HightlightRegex.Text = AppSettings.HighlightRegex;

            #endregion

            // JMF: Thinking about the user experience here, rolling out something that
            //      may very well invalidate their stored settings.  I'll just flag
            //      values that are now encrypted with a prefix when saved to the AppSetting.
            if (!AppSettings.ProxyPassword.StartsWith("WittyEncrypted:"))
                ProxyPasswordTextBox.Password = AppSettings.ProxyPassword;
            else
                ProxyPasswordTextBox.Password = DecryptString(AppSettings.ProxyPassword);

            ToggleProxyFieldsEnabled(AppSettings.UseProxy);

            if (!string.IsNullOrEmpty(AppSettings.MaximumIndividualAlerts))
            {
                MaxIndSlider.Value = Double.Parse(AppSettings.MaximumIndividualAlerts);
            }

            DisplayNotificationsCheckBox.IsChecked = AppSettings.DisplayNotifications;

            if (!string.IsNullOrEmpty(AppSettings.NotificationDisplayTime))
            {
                NotificationDisplayTimeSlider.Value = Double.Parse(AppSettings.NotificationDisplayTime);
            }

            //TODO:Figure out how to get auto-start working with ClickOnce and Vista
            //Until then, don't show the auto-start option
            if (Environment.OSVersion.Version.Major > 5 && ClickOnce.Utils.IsApplicationNetworkDeployed)
                RunAtStartupCheckBox.Visibility = Visibility.Collapsed;
        }
Exemple #7
0
 public void Login()
 {
     TwitterNet twitter = new TwitterNet(username, password);
     User user = twitter.Login();
     Assert.AreEqual(userId, user.Id);
 }
Exemple #8
0
 public void GetUser()
 {
     TwitterNet twitter = new TwitterNet(username,password);
     User user = twitter.GetUser(userId);
     Assert.AreEqual(username, user.ScreenName);
 }
Exemple #9
0
 public void GetFriendsWithId()
 {
     TwitterNet twitter = new TwitterNet(username, password);
     UserCollection uc = twitter.GetFriends(14203624);
     Assert.AreEqual(testUser.FollowingCount, uc.Count);
 }