Exemple #1
0
        private void Connect(GalleryAccount selected = null)
        {
            try {
                if (accounts.Count != 0 && connect)
                {
                    if (selected == null)
                    {
                        if (gallery_optionmenu.Active != -1)
                        {
                            account = accounts [gallery_optionmenu.Active];
                        }
                        else
                        {
                            account = accounts [0];
                        }
                    }
                    else
                    {
                        account = selected;
                    }

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

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

                Log.Exception(ex);
                PopulateAlbumOptionMenu(account.Gallery);
                album_button.Sensitive = false;

                new AccountDialog(export_dialog, account, true);
            }
        }
Exemple #2
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 ();

                    //Check for name uniqueness
                    foreach (GalleryAccount acc in GalleryAccountManager.GetInstance ().GetAccounts ())
                        if (acc.Name == name)
                            throw new ArgumentException ("name");
                    GalleryAccount created = new GalleryAccount (name,
                                             url,
                                             username,
                                             password);

                    created.Connect ();
                    GalleryAccountManager.GetInstance ().AddAccount (created);
                    account = created;
                } catch (System.UriFormatException) {
                    HigMessageDialog md =
                        new HigMessageDialog (add_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 (GalleryException e) {
                    HigMessageDialog md =
                        new HigMessageDialog (add_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) {
                        Log.Debug (e.Message);
                        Log.Debug (e.ResponseText);
                    }
                    md.Run ();
                    md.Destroy ();
                    return;
                } catch (ArgumentException ae) {
                    HigMessageDialog md =
                        new HigMessageDialog (add_dialog,
                                      Gtk.DialogFlags.Modal |
                                      Gtk.DialogFlags.DestroyWithParent,
                                      Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                      Catalog.GetString ("A Gallery with this name already exists"),
                                      String.Format (Catalog.GetString ("There is already a Gallery with the same name in your registered Galleries. Please choose a unique name.")));
                    Log.Exception (ae);
                    md.Run ();
                    md.Destroy ();
                    return;
                } catch (System.Net.WebException we) {
                    HigMessageDialog md =
                        new HigMessageDialog (add_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;
                } catch (System.Exception se) {
                    HigMessageDialog md =
                        new HigMessageDialog (add_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}"), se.Message));
                    Log.Exception (se);
                    md.Run ();
                    md.Destroy ();
                    return;
                }
            }
            add_dialog.Destroy ();
        }
Exemple #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();
                    }

                    //Check for name uniqueness
                    foreach (GalleryAccount acc in GalleryAccountManager.GetInstance().GetAccounts())
                    {
                        if (acc.Name == name)
                        {
                            throw new ArgumentException("name");
                        }
                    }
                    GalleryAccount created = new GalleryAccount(name,
                                                                url,
                                                                username,
                                                                password);

                    created.Connect();
                    GalleryAccountManager.GetInstance().AddAccount(created);
                    account = created;
                } catch (System.UriFormatException) {
                    HigMessageDialog md =
                        new HigMessageDialog(add_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 (GalleryException e) {
                    HigMessageDialog md =
                        new HigMessageDialog(add_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)
                    {
                        Log.Debug(e.Message);
                        Log.Debug(e.ResponseText);
                    }
                    md.Run();
                    md.Destroy();
                    return;
                } catch (ArgumentException ae) {
                    HigMessageDialog md =
                        new HigMessageDialog(add_dialog,
                                             Gtk.DialogFlags.Modal |
                                             Gtk.DialogFlags.DestroyWithParent,
                                             Gtk.MessageType.Error, Gtk.ButtonsType.Ok,
                                             Catalog.GetString("A Gallery with this name already exists"),
                                             string.Format(Catalog.GetString("There is already a Gallery with the same name in your registered Galleries. Please choose a unique name.")));
                    Log.Exception(ae);
                    md.Run();
                    md.Destroy();
                    return;
                } catch (System.Net.WebException we) {
                    HigMessageDialog md =
                        new HigMessageDialog(add_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;
                } catch (System.Exception se) {
                    HigMessageDialog md =
                        new HigMessageDialog(add_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}"), se.Message));
                    Log.Exception(se);
                    md.Run();
                    md.Destroy();
                    return;
                }
            }
            add_dialog.Destroy();
        }