/[projects]/smsdaemon/Spooler.cpp
ViewVC logotype

Diff of /smsdaemon/Spooler.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 132 by torben, Sun Dec 7 00:59:05 2008 UTC revision 134 by torben, Sun Dec 7 08:44:22 2008 UTC
# Line 38  void Spooler::enqueue(std::string recipi Line 38  void Spooler::enqueue(std::string recipi
38  {  {
39          bool error = false;          bool error = false;
40          lock();          lock();
41          std::string file = getSpoolFilename();          std::string file = findSpoolFilename();
42          std::ofstream out(file.c_str());          std::ofstream out(file.c_str());
43          if (out) {          if (out) {
44                  out << recipient << "\n" << message;                  out << recipient << "\n" << message;
# Line 50  void Spooler::enqueue(std::string recipi Line 50  void Spooler::enqueue(std::string recipi
50                    
51          if (error)          if (error)
52                  throw std::runtime_error("Could not create spoolfile");                  throw std::runtime_error("Could not create spoolfile");
53            this->filename = file;
54  }  }
55    
56  std::string Spooler::dequeue()  std::string Spooler::dequeue()
# Line 86  std::string Spooler::dequeue() Line 87  std::string Spooler::dequeue()
87    
88          unlock();          unlock();
89    
90            this->filename = file;
91    
92          if (file != "")          if (file != "")
93                  return message;                  return message;
94          else          else
95                  throw filenotfoundexception();                  throw filenotfoundexception();
96  }  }
97    
98  std::string Spooler::getSpoolFilename()  std::string Spooler::findSpoolFilename()
99  {  {
100          std::string file;          std::string file;
101          std::stringstream ss;          std::stringstream ss;
# Line 144  void Spooler::unlock() Line 147  void Spooler::unlock()
147  {  {
148          flock(fd, LOCK_UN);          flock(fd, LOCK_UN);
149  }  }
150    
151    string Spooler::getFilename()
152    {
153            return filename;
154    }

Legend:
Removed from v.132  
changed lines
  Added in v.134

  ViewVC Help
Powered by ViewVC 1.1.20