signon  8.58
signondisposable.h
Go to the documentation of this file.
00001 /*
00002  * This file is part of signon
00003  *
00004  * Copyright (C) 2010 Nokia Corporation.
00005  *
00006  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public License
00010  * version 2.1 as published by the Free Software Foundation.
00011  *
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00020  * 02110-1301 USA
00021  */
00022 
00023 #ifndef SIGNONDISPOSABLE_H_
00024 #define SIGNONDISPOSABLE_H_
00025 
00026 #include "signond-common.h"
00027 
00028 #include <QtCore>
00029 #include <time.h>
00030 
00031 namespace SignonDaemonNS {
00032 
00039 class SignonDisposable: public QObject
00040 {
00041     Q_OBJECT
00042 
00043 protected:
00044     virtual ~SignonDisposable();
00045 
00046 public:
00054     SignonDisposable(int maxInactivity, QObject *parent);
00055 
00060     virtual void destroy() { deleteLater(); }
00061 
00066     void keepInUse() const;
00067 
00073     void setAutoDestruct(bool value = true) const;
00074 
00083     static void invokeOnIdle(int maxInactivity,
00084                              QObject *object, const char *member);
00085 
00086 public Q_SLOTS:
00091     static void destroyUnused();
00092 
00093 private:
00094     int maxInactivity;
00095     mutable time_t lastActivity;
00096     mutable bool autoDestruct;
00097 }; //class SignonDaemon
00098 
00099 } //namespace SignonDaemonNS
00100 
00101 #endif /* SIGNONDISPOSABLE_H_ */