示例#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.Active];
                    }
                    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(String.Format(Catalog.GetString("Available space: {0}, {1}% used out of {2}"),
                                            GLib.Format.SizeForDisplay(ql - qu),
                                            (100 * qu / ql),
                                            GLib.Format.SizeForDisplay(ql)));
                    sb.Append("</small>");
                    status_label.Text      = sb.ToString();
                    status_label.UseMarkup = true;

                    album_button.Sensitive = true;
                }
            } catch (CaptchaException exc) {
                Log.Debug("Your Google account is locked");
                if (selected != null)
                {
                    account = selected;
                }

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

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

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

                PopulateAlbumOptionMenu(account.Picasa);

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

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