Buteo Synchronization Framework
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>
29extern "C" {
30#include "iphbd/libiphb.h"
31}
32
33namespace Buteo {
34
38class IPHeartBeat : public QObject
39{
40 Q_OBJECT
41
43 struct BeatStruct {
44 int sockfd;
45 QSocketNotifier *sockNotifier;
46 iphb_t iphbHandle;
47 };
48
49public:
53 IPHeartBeat(QObject *aParent);
54
58 virtual ~IPHeartBeat();
59
68 bool setHeartBeat(const QString &aProfName, ushort aMinWaitTime, ushort aMaxWaitTime);
69
74 void removeWait(const QString &aProfName);
75
78 void removeAllWaits();
79
80signals:
85 void onHeartBeat(QString aProfName);
86
87private slots:
88
93 void internalBeatTriggered(int aSockFd);
94
95private:
96
103 bool getProfNameFromFd(int aSockFd, QString &aProfName);
104
105private:
107 QMap<QString, BeatStruct> iBeatsWaiting;
108
109#ifdef SYNCFW_UNIT_TESTS
110 friend class IPHeartBeatTest;
111#endif
112};
113
114}
115
116#endif
IPHeartBeat implementation.
Definition IPHeartBeat.h:39
void removeWait(const QString &aProfName)
Removes heart beat waiting for a profile.
Definition IPHeartBeat.cpp:59
void removeAllWaits()
Removes heart beat waiting for all profiles.
Definition IPHeartBeat.cpp:42
void onHeartBeat(QString aProfName)
This signal will be emitted when a heartbeat for particular profile is triggered.
bool setHeartBeat(const QString &aProfName, ushort aMinWaitTime, ushort aMaxWaitTime)
Schedules a heartbeat for this profile between minWaitTime and maxWaitTime.
Definition IPHeartBeat.cpp:97
virtual ~IPHeartBeat()
Destructor.
Definition IPHeartBeat.cpp:35
Definition SyncBackupAdaptor.h:41