예제 #1
0
        private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            AuthenticateClass token = GetToken.getAuthClass();

            StatusClass.postStatus(token, TootContents.Text, in_reply_to_id, null, null, null);
            Hide();
        }
예제 #2
0
        public WritingToot(string replyto)
        {
            this.InitializeComponent();
            in_reply_to_id = replyto;
            AuthenticateClass token  = GetToken.getAuthClass();
            StatusClass_new   status = new StatusClass_new();

            status.id         = in_reply_to_id;
            TootContents.Text = (StatusClass_new.GetStatus(new HttpConnectionClass(token), status)).account.acct + " ";
        }
예제 #3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var isDark = Application.Current.RequestedTheme == ApplicationTheme.Dark;

            if (isDark)
            {
                SPanel.Background = new SolidColorBrush(Windows.UI.Colors.Black);
            }
            StatusClass_new     toot_id  = (StatusClass_new)e.Parameter;
            HttpConnectionClass token    = new HttpConnectionClass(GetToken.getAuthClass());
            StatusContext       statuses = StatusClass_new.GetStatusContext(token, toot_id);

            StatusClass_new[] tootlist = statuses.ancestors;
            for (int i = 0; i < tootlist.Length; i++)
            {
                Toot toot;
                if (tootlist[i].account.acct != null)
                {
                    toot = new Toot(tootlist[i], 0);
                    TootContainer.Items.Add(toot);
                }
            }
            tootlist = statuses.descendants;
            toot_id  = StatusClass_new.GetStatus(token, toot_id);
            Toot firstoot = new Toot(toot_id, 1);

            firstoot.Height = 300;
            TootContainer.Items.Add(firstoot);
            for (int i = 0; i < tootlist.Length; i++)
            {
                Toot toot;
                if (tootlist[i].account.acct != null)
                {
                    toot = new Toot(tootlist[i], 0);
                    TootContainer.Items.Add(toot);
                }
            }
        }
예제 #4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var isDark = Application.Current.RequestedTheme == ApplicationTheme.Dark;

            if (isDark)
            {
                SPanel.Background = new SolidColorBrush(Windows.UI.Colors.Black);
            }
            account = (AccountClass)e.Parameter;
            if (account.header[0] == 'h')
            {
                bgimage.Source = new BitmapImage(new Uri(account.header));
            }
            else
            {
                bgimage.Source = new BitmapImage(new Uri("https://" + (GetToken.getServerName()) + account.header));
            }
            Tootername.Text = account.display_name + "\n" + account.acct;
            StatusClass_new[] statuses = StatusClass_new.GetAccountStatuses(new HttpConnectionClass(GetToken.getAuthClass()), account);
            for (int i = 0; i < statuses.Length; i++)
            {
                Toot toot;
                if (statuses[i].account.acct != null)
                {
                    toot = new Toot(statuses[i], 0);
                    TootContainer.Items.Add(toot);
                }
            }
        }
예제 #5
0
 private void Follow_Click(object sender, RoutedEventArgs e)
 {
     AccountClass.follow(account, GetToken.getAuthClass());
     Follow.IsEnabled = false;
 }
예제 #6
0
 private async void ImageShow_Click(object sender, RoutedEventArgs e)
 {
     StatusClass_new st            = StatusClass_new.GetStatus(new HttpConnectionClass(GetToken.getAuthClass()), toot);
     var             contentDialog = new ShowImage_Toot(st);
     await contentDialog.ShowAsync();
 }
예제 #7
0
 private void Favorites_Click(object sender, RoutedEventArgs e)
 {
     StatusClass.favourite_toot(toot.id, GetToken.getAuthClass());
     Favorites.Foreground = new SolidColorBrush(Windows.UI.Colors.Yellow);
 }
예제 #8
0
 private void Retoot_Click(object sender, RoutedEventArgs e)
 {
     StatusClass.boost_toot(toot_id, GetToken.getAuthClass());
     Retoot.Foreground = new SolidColorBrush(Windows.UI.Colors.Green);
 }
예제 #9
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var isDark = Application.Current.RequestedTheme == ApplicationTheme.Dark;

            if (isDark)
            {
                SPanel.Background = new SolidColorBrush(Windows.UI.Colors.Black);
            }
            TootCollectionBind        = new ObservableCollection <object>();
            TootContainer.DataContext = TootCollectionBind;
            base.OnNavigatedTo(e);
            var settings = (string)e.Parameter;
            HttpConnectionClass token = new HttpConnectionClass(GetToken.getAuthClass());

            //List<StatusClass> tootlist = null;
            StatusClass_new[] tootlist;
            string            baseuri = "https://" + token.auth.server;

            if (baseuri != "https://mamot.fr")
            {
                if (settings == "notifications")
                {
                    baseuri = baseuri + "/api/v1/streaming/user";
                }
                else if (settings == "PublicTimeline")
                {
                    baseuri = baseuri + "/api/v1/streaming/public";
                }
                else if (settings == "LocalPublicTimeline")
                {
                    baseuri = baseuri + "/api/v1/streaming/public?local=true";
                }
                else
                {
                    baseuri = baseuri + "/api/v1/streaming/user";
                }
            }
            else
            {
                if (settings == "notifications")
                {
                    baseuri = baseuri + "/api/v1/streaming/user";
                }
                else if (settings == "PublicTimeline")
                {
                    baseuri = baseuri + "/api/v1/streaming/public";
                }
                else if (settings == "LocalPublicTimeline")
                {
                    baseuri = baseuri + "/api/v1/streaming/public?local=true";
                }
                else
                {
                    // even this doesn't work on the LQDN instance... it's just broken
                    baseuri = baseuri + "/api/v1/streaming/?&access_token=" + token.auth.token + "&stream=user";
                }
            }
            HttpClient client = token.client;

            tootrefresh = ThreadPool.RunAsync(async(source) =>
            {
                Stream msg;
                try
                {
                    msg = await client.GetStreamAsync(baseuri);
                }
                catch
                {
                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, (async() =>
                    {
                        var errorDialog = new ContentDialog
                        {
                            Name = "Connection error",
                            Title = "Streaming doesn't currently work properly. The app will work with reduced functionallity.",
                            IsPrimaryButtonEnabled = false,
                            SecondaryButtonText = "ok"
                        };
                        await errorDialog.ShowAsync();
                    }));
                    return;
                }
                while (1 == 1)
                {
                    var st      = new StreamReader(msg);
                    string text = st.ReadLine();
                    if (text == null)
                    {
                        try
                        {
                            msg = await client.GetStreamAsync(baseuri); // reset the connection
                        }
                        catch
                        {
                            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, (async() =>
                            {
                                var errorDialog = new ContentDialog
                                {
                                    Name = "Connection error",
                                    Title = "Streaming doesn't currently work properly. The app will work with reduced functionallity.",
                                    IsPrimaryButtonEnabled = false,
                                    SecondaryButtonText = "ok"
                                };
                                await errorDialog.ShowAsync();
                            }));
                            return;
                        }
                    }
                    else if ((text.ToArray())[0] != ':')
                    {
                        string[] text2   = text.Split(':');
                        var intermediate = (text.Split('\n'));
                        string text3     = intermediate.Aggregate((a, b) => a + b);
                        string stdata    = st.ReadLine();
                        stdata           = new string(stdata.Skip(5).ToArray());
                        if (text2[1] == " delete")
                        {
                            st.DiscardBufferedData();
                        }
                        if (text2[1] == " update")
                        {
                            while (stdata.Last() != '}')
                            {
                                stdata = stdata + st.ReadLine();
                            }
                            StatusClass_new status = StatusClass_new.parseToot(stdata);
                            // Insert at the beginning
                            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, (() =>
                            {
                                Toot toot = new Toot(status);
                                TootCollectionBind.Add(toot);
                            }));
                        }
                        else if (text2[1] == " notification")
                        {
                            NotificationClass_new notification = NotificationClass_new.parseNotification(stdata);
                            if (notification.id != null)
                            {
                                if (notification.type == "favourite")
                                {
                                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, (() =>
                                    {
                                        TextBlock block = new TextBlock();
                                        Toot toot;
                                        if (notification.account.display_name != "")
                                        {
                                            block.Text = notification.account.display_name + " favourited your post.";
                                        }
                                        else
                                        {
                                            block.Text = notification.account.acct + " favourited your post.";
                                        }
                                        toot = new Toot(notification.status);
                                        TootCollectionBind.Add(block);
                                        TootCollectionBind.Add(toot);
                                    }));
                                }
                                if (notification.type == "reblog")
                                {
                                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, (() =>
                                    {
                                        TextBlock block = new TextBlock();
                                        Toot toot;
                                        if (notification.account.display_name != "")
                                        {
                                            block.Text = notification.account.display_name + " boosted your post.";
                                        }
                                        else
                                        {
                                            block.Text = notification.account.acct + " boosted your post.";
                                        }
                                        toot = new Toot(notification.status);
                                        TootCollectionBind.Add(block);
                                        TootCollectionBind.Add(toot);
                                    }));
                                }
                                if (notification.type == "follow")
                                {
                                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, (() =>
                                    {
                                        TextBlock block = new TextBlock();
                                        if (notification.account.display_name == "")
                                        {
                                            block.Text = notification.account.display_name + " now follows you.";
                                        }
                                        else
                                        {
                                            block.Text = notification.account.acct + " now follows you.";
                                        }
                                        TootCollectionBind.Add(block);
                                    }));
                                }
                                if (notification.type == "mention")
                                {
                                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, (() =>
                                    {
                                        Toot toot;
                                        toot = new Toot(notification.status);
                                        TootCollectionBind.Add(toot);
                                    }));
                                }
                            }
                        }
                    }
                }
            }
                                              );

            if (settings != "notifications")
            {
                if (settings == "PublicTimeline")
                {
                    //tootlist = StatusClass.getPublicTimeline(token);
                    tootlist = StatusClass_new.GetPublicTimeline(token);
                }
                else if (settings == "LocalPublicTimeline")
                {
                    tootlist = StatusClass_new.GetPublicLocalTimeline(token);
                }
                else
                {
                    tootlist = StatusClass_new.GetTimeline(token);
                }
                for (int i = tootlist.Length - 1; i >= 0; i--)
                {
                    Toot toot;
                    toot = new Toot(tootlist[i]);
                    TootCollectionBind.Add(toot);
                }
            }
            else
            {
                NotificationClass_new[] notifications = NotificationClass_new.getNotifications(token);
                for (int i = notifications.Length - 1; i >= 0; i--)
                {
                    if (notifications[i].id != null)
                    {
                        if (notifications[i].type == "favourite")
                        {
                            TextBlock block = new TextBlock();
                            Toot      toot;
                            if (notifications[i].account.display_name != "")
                            {
                                block.Text = notifications[i].account.display_name + " favourited your post.";
                            }
                            else
                            {
                                block.Text = notifications[i].account.acct + " favourited your post.";
                            }
                            toot = new Toot(notifications[i].status);
                            TootCollectionBind.Add(block);
                            TootCollectionBind.Add(toot);
                        }
                        if (notifications[i].type == "reblog")
                        {
                            TextBlock block = new TextBlock();
                            Toot      toot;
                            if (notifications[i].account.display_name != "")
                            {
                                block.Text = notifications[i].account.display_name + " boosted your post.";
                            }
                            else
                            {
                                block.Text = notifications[i].account.acct + " boosted your post.";
                            }
                            toot = new Toot(notifications[i].status);
                            TootCollectionBind.Add(block);
                            TootCollectionBind.Add(toot);
                        }
                        if (notifications[i].type == "follow")
                        {
                            TextBlock block = new TextBlock();
                            if (notifications[i].account.display_name != "")
                            {
                                block.Text = notifications[i].account.display_name + " now follows you.";
                            }
                            else
                            {
                                block.Text = notifications[i].account.acct + " now follows you.";
                            }
                            TootCollectionBind.Add(block);
                        }
                        if (notifications[i].type == "mention")
                        {
                            Toot toot;
                            toot = new Toot(notifications[i].status);
                            TootCollectionBind.Add(toot);
                        }
                    }
                }
            }
        }