Beispiel #1
0
        private void Connect(GoogleAccount selected, string token, string text)
        {
            try {
                if (accounts.Count != 0 && connect)
                {
                    if (selected == null)
                    {
                        account = (GoogleAccount)accounts [gallery_optionmenu.History];
                    }
                    else
                    {
                        account = selected;
                    }

                    if (!account.Connected)
                    {
                        account.Connect();
                    }

                    PopulateAlbumOptionMenu(account.Picasa);

                    long qu = account.Picasa.QuotaUsed;
                    long ql = account.Picasa.QuotaLimit;

                    StringBuilder sb = new StringBuilder("<small>");
                    sb.Append(Catalog.GetString("Available space :"));
                    sb.Append(SizeUtil.ToHumanReadable(ql - qu));
                    sb.Append(" (");
                    sb.Append(100 * qu / ql);
                    sb.Append("% used out of ");
                    sb.Append(SizeUtil.ToHumanReadable(ql));
                    sb.Append(")");
                    sb.Append("</small>");

                    status_label.Text      = sb.ToString();
                    status_label.UseMarkup = true;

                    album_button.Sensitive = true;
                }
            } catch (CaptchaException exc) {
                System.Console.WriteLine("Your google account is locked");
                if (selected != null)
                {
                    account = selected;
                }

                PopulateAlbumOptionMenu(account.Picasa);
                album_button.Sensitive = false;

                new GoogleAccountDialog(this.Dialog, account, false, exc);

                System.Console.WriteLine("Your google account is locked, you can unlock it by visiting: {0}", CaptchaException.UnlockCaptchaURL);
            } catch (System.Exception) {
                System.Console.WriteLine("Can not connect to Picasa. Bad username ? password ? network connection ?");
                //System.Console.WriteLine ("{0}",ex);
                if (selected != null)
                {
                    account = selected;
                }

                PopulateAlbumOptionMenu(account.Picasa);

                status_label.Text      = String.Empty;
                album_button.Sensitive = false;

                new GoogleAccountDialog(this.Dialog, account, true, null);
            }
        }