Merge 1.0
[dcpomatic.git] / src / tools / dcpomatic.cc
index 420d828b0730635f4c6a36ac9110f9a09e88cb00..891c4623ca9b6e1ea1ac995d41108d119468e72f 100644 (file)
@@ -53,6 +53,8 @@
 #include "lib/exceptions.h"
 #include "lib/cinema.h"
 #include "lib/kdm.h"
+#include "lib/send_kdm_email_job.h"
+#include "lib/server_finder.h"
 
 using std::cout;
 using std::string;
@@ -244,6 +246,7 @@ class Frame : public wxFrame
 public:
        Frame (wxString const & title)
                : wxFrame (NULL, -1, title)
+               , _hints_dialog (0)
                , _servers_list_dialog (0)
        {
 #ifdef DCPOMATIC_WINDOWS_CONSOLE               
@@ -347,7 +350,7 @@ private:
                                            std_to_wx (
                                                    String::compose (wx_to_std (_("The directory %1 already exists and is not empty.  "
                                                                                  "Are you sure you want to use it?")),
-                                                                    d->get_path().c_str())
+                                                                    d->get_path().string().c_str())
                                                    )
                                            )) {
                                        return;
@@ -458,7 +461,9 @@ private:
                        if (d->write_to ()) {
                                write_kdm_files (film, d->screens (), d->dcp (), d->from (), d->until (), d->directory ());
                        } else {
-                               email_kdms (film, d->screens (), d->dcp (), d->from (), d->until ());
+                               JobManager::instance()->add (
+                                       shared_ptr<Job> (new SendKDMEmailJob (film, d->screens (), d->dcp (), d->from (), d->until ()))
+                                       );
                        }
                } catch (KDMError& e) {
                        error_dialog (this, e.what ());
@@ -548,6 +553,8 @@ private:
                        return;
                }
 
+               maybe_save_then_delete_film ();
+
                ev.Skip ();
        }
 
@@ -626,8 +633,12 @@ class App : public wxApp
                f->Show ();
 
                ui_signaller = new wxUISignaller (this);
-               this->Bind (wxEVT_IDLE, boost::bind (&App::idle, this));
+               Bind (wxEVT_IDLE, boost::bind (&App::idle, this));
 
+               Bind (wxEVT_TIMER, boost::bind (&App::check, this));
+               _timer.reset (new wxTimer (this));
+               _timer->Start (1000);
+               
                return true;
        }
        catch (exception& e)
@@ -664,6 +675,17 @@ class App : public wxApp
        {
                ui_signaller->ui_idle ();
        }
+
+       void check ()
+       {
+               try {
+                       ServerFinder::instance()->rethrow ();
+               } catch (exception& e) {
+                       error_dialog (0, std_to_wx (e.what ()));
+               }
+       }
+
+       shared_ptr<wxTimer> _timer;
 };
 
 IMPLEMENT_APP (App)