Esempio n. 1
0
        private void Connect(GalleryAccount selected)
        {
            try {
                if (accounts.Count != 0 && connect)
                {
                    if (selected == null)
                    {
                        account = (GalleryAccount)accounts [gallery_optionmenu.History];
                    }
                    else
                    {
                        account = selected;
                    }

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

                    PopulateAlbumOptionMenu(account.Gallery);
                    album_button.Sensitive = true;
                }
            } catch (System.Exception ex) {
                if (selected != null)
                {
                    account = selected;
                }

                System.Console.WriteLine("{0}", ex);
                PopulateAlbumOptionMenu(account.Gallery);
                album_button.Sensitive = false;

                new AccountDialog(this.Dialog, account, true);
            }
        }
		protected void HandleAddResponse (object sender, Gtk.ResponseArgs args)
		{
			if (args.ResponseId == Gtk.ResponseType.Ok) {
				try {
					Uri uri = new Uri (url);
					if (uri.Scheme != Uri.UriSchemeHttp &&
					    uri.Scheme != Uri.UriSchemeHttps)
						throw new System.UriFormatException ();
					
					GalleryAccount created = new GalleryAccount (name, 
										     url, 
										     username,
										     password);
					
					created.Connect ();
					GalleryAccountManager.GetInstance ().AddAccount (created);
					account = created;
				} catch (System.UriFormatException) {
					
					HigMessageDialog md = 
						new HigMessageDialog (Dialog, 
								      Gtk.DialogFlags.Modal |
								      Gtk.DialogFlags.DestroyWithParent,
								      Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
								      Catalog.GetString ("Invalid URL"),
								      Catalog.GetString ("The gallery URL entry does not appear to be a valid URL"));
					md.Run ();
					md.Destroy ();
					return;
				} catch (GalleryRemote.GalleryException e) {
					HigMessageDialog md = 
						new HigMessageDialog (Dialog, 
								      Gtk.DialogFlags.Modal |
								      Gtk.DialogFlags.DestroyWithParent,
								      Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
								      Catalog.GetString ("Error while connecting to Gallery"),
								      String.Format (Catalog.GetString ("The following error was encountered while attempting to log in: {0}"), e.Message));
					if (e.ResponseText != null) {
						System.Console.WriteLine (e.Message);
						System.Console.WriteLine (e.ResponseText);
					}
					md.Run ();
					md.Destroy ();
					return;
				} catch (System.Net.WebException we) {
					HigMessageDialog md = 
						new HigMessageDialog (Dialog, 
								      Gtk.DialogFlags.Modal |
								      Gtk.DialogFlags.DestroyWithParent,
								      Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
								      Catalog.GetString ("Error while connecting to Gallery"),
								      String.Format (Catalog.GetString ("The following error was encountered while attempting to log in: {0}"), we.Message));
					md.Run ();
					md.Destroy ();
					return;
				}
			}
			Dialog.Destroy ();
		}
Esempio n. 3
0
        protected void HandleAddResponse(object sender, Gtk.ResponseArgs args)
        {
            if (args.ResponseId == Gtk.ResponseType.Ok)
            {
                try {
                    Uri uri = new Uri(url);
                    if (uri.Scheme != Uri.UriSchemeHttp &&
                        uri.Scheme != Uri.UriSchemeHttps)
                    {
                        throw new System.UriFormatException();
                    }

                    GalleryAccount created = new GalleryAccount(name,
                                                                url,
                                                                username,
                                                                password);

                    created.Connect();
                    GalleryAccountManager.GetInstance().AddAccount(created);
                    account = created;
                } catch (System.UriFormatException) {
                    HigMessageDialog md =
                        new HigMessageDialog(Dialog,
                                             Gtk.DialogFlags.Modal |
                                             Gtk.DialogFlags.DestroyWithParent,
                                             Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                             Catalog.GetString("Invalid URL"),
                                             Catalog.GetString("The gallery URL entry does not appear to be a valid URL"));
                    md.Run();
                    md.Destroy();
                    return;
                } catch (GalleryRemote.GalleryException e) {
                    HigMessageDialog md =
                        new HigMessageDialog(Dialog,
                                             Gtk.DialogFlags.Modal |
                                             Gtk.DialogFlags.DestroyWithParent,
                                             Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                             Catalog.GetString("Error while connecting to Gallery"),
                                             String.Format(Catalog.GetString("The following error was encountered while attempting to log in: {0}"), e.Message));
                    if (e.ResponseText != null)
                    {
                        System.Console.WriteLine(e.Message);
                        System.Console.WriteLine(e.ResponseText);
                    }
                    md.Run();
                    md.Destroy();
                    return;
                } catch (System.Net.WebException we) {
                    HigMessageDialog md =
                        new HigMessageDialog(Dialog,
                                             Gtk.DialogFlags.Modal |
                                             Gtk.DialogFlags.DestroyWithParent,
                                             Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                             Catalog.GetString("Error while connecting to Gallery"),
                                             String.Format(Catalog.GetString("The following error was encountered while attempting to log in: {0}"), we.Message));
                    md.Run();
                    md.Destroy();
                    return;
                }
            }
            Dialog.Destroy();
        }