      1  #include "message.h"
      2  #include "mailbox.h"
      3
      4  Message* Mailbox::get_current_message() const
      5  {
      6     if (new_messages.size() > 0)
      7        return new_messages.front();
      8     if (kept_messages.size() > 0)
      9        return kept_messages.front();
     10     return NULL;
     11  }
     12
     13  void Mailbox::remove_current_message()
     14  {
     15     if (new_messages.size() > 0)
     16     {
     17        Message* m = get_current_message();
     18        new_messages.pop();
     19        delete m;
     20     }
     21     else if (kept_messages.size() > 0)
     22     {
     23        Message* m = get_current_message();
     24        kept_messages.pop();
     25        delete m;
     26     }
     27  }
     28
     29  void Mailbox::save_current_message()
     30  {
     31     Message* m = get_current_message();
     32     if (m != NULL)
     33     {
     34        kept_messages.push(new Message(*m));
     35        remove_current_message();
     36     }
     37  }