]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlVCLog.C
John's character.C patch (bug fix).
[lyx.git] / src / frontends / controllers / ControlVCLog.C
index 83c71f7bfaa73f65913c0cb7cdf86e51ddabdeef..cc0ad7f7790f8d41d25672c7e76759a5edf4a912 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of
- * ====================================================== 
+ * ======================================================
  *
  *           LyX, The Document Processor
  *
  * \author Angus Leeming <a.leeming@ic.ac.uk>
  */
 
+#include <config.h>
+#include <fstream>
+#include "Lsstream.h"
+
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-#include <config.h>
+#include "ViewBase.h"
+#include "ButtonControllerBase.h"
 #include "ControlVCLog.h"
 #include "buffer.h"
+#include "BufferView.h"
 #include "LyXView.h"
 #include "Dialogs.h"
 #include "lyxrc.h"
+#include "support/lyxlib.h"
 
 using SigC::slot;
+using std::endl;
 
 ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
        : ControlDialog<ControlConnectBD>(lv, d)
@@ -31,19 +39,31 @@ ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
        d_.showVCLogFile.connect(slot(this, &ControlVCLog::show));
 }
 
-// FIXME: this is all wrong, getLogFile() actually creates a file
-// which we must unlink.
-
-// FIXME: I need to get the Buffer Filename for my window title, need
-// to add to params. 
-
-void ControlVCLog::setParams()
+string const ControlVCLog::getBufferFileName() const
 {
-       logfile_ = lv_.view()->buffer()->lyxvc.getLogFile();
+       return lv_.view()->buffer()->fileName();
 }
 
 
-void ControlVCLog::clearParams()
+stringstream & ControlVCLog::getVCLogFile(stringstream & ss) const
 {
-       logfile_.erase();
+       string const name = lv_.view()->buffer()->lyxvc.getLogFile();
+
+       std::ifstream in(name.c_str());
+
+       bool found = (in.get());
+
+       if (found) {
+               in.seekg(0, std::ios::beg); // rewind to the beginning
+
+               ss << in.rdbuf();
+               found = ss.good();
+       }
+       
+       if (!found)
+               ss << "No version control log file found." << endl;
+
+       lyx::unlink(name);
+
+       return ss;
 }