+ bformat(_("Error while reading the configuration file\n%1$s.\n"
+ "Please check your installation."), from_utf8(error)));
+}
+
+
+void reconfigureUserLyXDir()
+{
+ string const configure_command = package().configure_command();
+
+ lyxerr << to_utf8(_("LyX: reconfiguring user directory")) << endl;
+ support::Path p(package().user_support());
+ Systemcall one;
+ one.startscript(Systemcall::Wait, configure_command);
+ lyxerr << "LyX: " << to_utf8(_("Done!")) << endl;
+}
+
+} // namespace anon
+
+
+/// The main application class private implementation.
+struct LyX::Singletons
+{
+ /// our function handler
+ LyXFunc lyxfunc_;
+ ///
+ BufferList buffer_list_;
+ ///
+ boost::scoped_ptr<kb_keymap> toplevel_keymap_;
+ ///
+ boost::scoped_ptr<LyXServer> lyx_server_;
+ ///
+ boost::scoped_ptr<LyXServerSocket> lyx_socket_;
+ ///
+ boost::scoped_ptr<frontend::Application> application_;
+ /// lyx session, containing lastfiles, lastfilepos, and lastopened
+ boost::scoped_ptr<Session> session_;
+};
+
+
+boost::scoped_ptr<LyX> LyX::singleton_;
+
+
+int LyX::exec(int & argc, char * argv[])
+{
+ BOOST_ASSERT(!singleton_.get());
+ // We must return from this before launching the gui so that
+ // other parts of the code can access singleton_ through
+ // LyX::ref and LyX::cref.
+ singleton_.reset(new LyX);
+ // Start the real execution loop.
+ return singleton_->priv_exec(argc, argv);
+}
+
+
+LyX & LyX::ref()
+{
+ BOOST_ASSERT(singleton_.get());
+ return *singleton_.get();
+}
+
+
+LyX const & LyX::cref()
+{
+ BOOST_ASSERT(singleton_.get());
+ return *singleton_.get();
+}
+
+
+LyX::LyX()
+ : first_start(false), geometryOption_(false)
+{
+ pimpl_.reset(new Singletons);
+}
+
+
+BufferList & LyX::bufferList()
+{
+ return pimpl_->buffer_list_;
+}
+
+
+BufferList const & LyX::bufferList() const
+{
+ return pimpl_->buffer_list_;
+}
+
+
+Session & LyX::session()
+{
+ BOOST_ASSERT(pimpl_->session_.get());
+ return *pimpl_->session_.get();
+}
+
+
+Session const & LyX::session() const
+{
+ BOOST_ASSERT(pimpl_->session_.get());
+ return *pimpl_->session_.get();
+}
+
+
+LyXFunc & LyX::lyxFunc()
+{
+ return pimpl_->lyxfunc_;
+}
+
+
+LyXFunc const & LyX::lyxFunc() const
+{
+ return pimpl_->lyxfunc_;
+}
+
+
+LyXServer & LyX::server()
+{
+ BOOST_ASSERT(pimpl_->lyx_server_.get());
+ return *pimpl_->lyx_server_.get();
+}
+
+
+LyXServer const & LyX::server() const
+{
+ BOOST_ASSERT(pimpl_->lyx_server_.get());
+ return *pimpl_->lyx_server_.get();
+}
+
+
+LyXServerSocket & LyX::socket()
+{
+ BOOST_ASSERT(pimpl_->lyx_socket_.get());
+ return *pimpl_->lyx_socket_.get();
+}
+
+
+LyXServerSocket const & LyX::socket() const
+{
+ BOOST_ASSERT(pimpl_->lyx_socket_.get());
+ return *pimpl_->lyx_socket_.get();