ButeoSynchronizationFramework
IPHeartBeat.h
1 /*
2  * This file is part of buteo-syncfw package
3  *
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5  *
6  * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * version 2.1 as published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23 #ifndef IPHEARTBEAT_H
24 #define IPHEARTBEAT_H
25 
26 #include <QObject>
27 #include <QMap>
28 #include <QSocketNotifier>
29 extern "C" {
30  #include "iphbd/libiphb.h"
31 }
32 
33 namespace Buteo {
34 
38 class IPHeartBeat : public QObject
39 {
40  Q_OBJECT
41 
43  struct BeatStruct
44  {
45  int sockfd;
46  QSocketNotifier* sockNotifier;
47  iphb_t iphbHandle;
48  };
49 
50 public:
54  IPHeartBeat(QObject *aParent);
55 
59  virtual ~IPHeartBeat();
60 
69  bool setHeartBeat(const QString& aProfName, ushort aMinWaitTime, ushort aMaxWaitTime);
70 
75  void removeWait(const QString& aProfName);
76 
79  void removeAllWaits();
80 
81 signals:
82 
87  void onHeartBeat(QString aProfName);
88 
89 
90 private slots:
91 
96  void internalBeatTriggered(int aSockFd);
97 
98 
99 private:
100 
107  bool getProfNameFromFd(int aSockFd, QString& aProfName);
108 
109 
110 private:
111 
113  QMap<QString, BeatStruct> iBeatsWaiting;
114 
115 #ifdef SYNCFW_UNIT_TESTS
116  friend class IPHeartBeatTest;
117 #endif
118 
119 };
120 
121 }
122 
123 #endif
void removeAllWaits()
Removes heart beat waiting for all profiles.
Definition: IPHeartBeat.cpp:42
void removeWait(const QString &aProfName)
Removes heart beat waiting for a profile.
Definition: IPHeartBeat.cpp:59
Definition: AccountsHelper.h:31
virtual ~IPHeartBeat()
Destructor.
Definition: IPHeartBeat.cpp:35
void onHeartBeat(QString aProfName)
This signal will be emitted when a heartbeat for particular profile is triggered. ...
Definition: moc_IPHeartBeat.cpp:132
IPHeartBeat implementation.
Definition: IPHeartBeat.h:38
IPHeartBeat(QObject *aParent)
Constructor.
Definition: IPHeartBeat.cpp:29
bool setHeartBeat(const QString &aProfName, ushort aMinWaitTime, ushort aMaxWaitTime)
Schedules a heartbeat for this profile between minWaitTime and maxWaitTime.
Definition: IPHeartBeat.cpp:97