#ifndef MountieMemory_h
#define MountieMemory_h

#include <QtGui>
#include <sys/types.h>
#include "MountieHistory.h"

// Class to remember stuff from run to run. Uses QSettings, but arranges to
// have the file read and written as the effective user who owns $HOME (so
// you can run mountie via sudo or as a setuid root program, but still
// access personalized settings).
//
class MountieMemory {
private:

   MountieMemory();

   MountieMemory(const MountieMemory & cpy);

   ~MountieMemory();

   MountieMemory &
   operator =(const MountieMemory & cpy);

public:

   static MountieMemory *
   Get();

   QSize
   GetSize();

   void
   SaveSize(const QSize & new_size);

   bool
   GetStayOpen();

   void
   SaveStayOpen(bool new_stay_open);

   QString
   GetProgname();

   void
   SaveProgname(QString new_progname);

   bool
   GetKeepHistory();

   void
   SaveKeepHistory(bool new_keep_history);

   void
   GetHistory(QComboBox * combo);

   void
   SaveHistory(QString mountpoint);

private:

   void
   ReadHistory(MountieHistoryList & hist);

   void
   WriteHistory(MountieHistoryList & hist);

   int
   FindHistory(MountieHistoryList & hist, QString mountpoint);

   static QString
   MountieFileName();

   static void
   SetHomeUser();

   static void
   SetMyUser();

   static MountieMemory * the_one;

   static uid_t my_uid;
   static gid_t my_gid;
   static uid_t home_uid;
   static gid_t home_gid;

   QSettings settings;
};

#endif // MountieMemory_h
