~mateo-salta/nitroshare/nitroshare

4 by Nathan Osman
Added initial IP multicast code.
1
/* NitroShare - A simple network file sharing tool.
2
   Copyright (C) 2012 Nathan Osman
3
4
   This program is free software: you can redistribute it and/or modify
5
   it under the terms of the GNU General Public License as published by
6
   the Free Software Foundation, either version 3 of the License, or
7
   (at your option) any later version.
8
9
   This program is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
   GNU General Public License for more details.
13
14
   You should have received a copy of the GNU General Public License
15
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
16
17
#ifndef CBROADCASTSERVER_H
18
#define CBROADCASTSERVER_H
19
16 by Nathan Osman
Moved some common networking code to defaults.h/cpp and increased the default broadcast timeout to 8 seconds.
20
#include <QHostAddress>
13 by Nathan Osman
Implemented basic notification for new PCs joining the network.
21
#include <QMap>
4 by Nathan Osman
Added initial IP multicast code.
22
#include <QTimer>
13 by Nathan Osman
Implemented basic notification for new PCs joining the network.
23
#include <QSystemTrayIcon>
4 by Nathan Osman
Added initial IP multicast code.
24
96 by Nathan Osman
Created an intermediate class, CBasicBroadcastServer, which will receive most of the functionality that CBroadcastServer currently has.
25
#include <discovery/CBasicBroadcastServer.h>
29 by Nathan Osman
Moved the discovery source files to a separate folder.
26
#include <discovery/CMachine.h>
12 by Nathan Osman
Made some further modifications to the way broadcast messages were sent / received.
27
96 by Nathan Osman
Created an intermediate class, CBasicBroadcastServer, which will receive most of the functionality that CBroadcastServer currently has.
28
class CBroadcastServer : public CBasicBroadcastServer
4 by Nathan Osman
Added initial IP multicast code.
29
{
30
    Q_OBJECT
31
32
    public:
33
34
        CBroadcastServer();
35
36
        void Init();
74 by Nathan Osman
Switched from using the hostname in the machine map to using a uniquely generated UUID to identify each machine.
37
38
        MachineMap GetMachineMap() { return m_machines; }
86 by Nathan Osman
Updated status icons for the share box.
39
        bool AnyMachinesOnline() { return m_machines.size(); }
40
        bool MachineExists(QString id) { return m_machines.contains(id); }
41
        CMachine GetMachine(QString id) { return m_machines[id]; }
4 by Nathan Osman
Added initial IP multicast code.
42
43
    private slots:
44
45
        void OnMessage();
46
        void OnTimer();
47
48
    private:
49
74 by Nathan Osman
Switched from using the hostname in the machine map to using a uniquely generated UUID to identify each machine.
50
        void UpdateMachineEntry(QHostAddress, QString, QByteArray, quint16, qint64);
51
        void CheckForExpiredMachines();
13 by Nathan Osman
Implemented basic notification for new PCs joining the network.
52
17 by Nathan Osman
Added improved error checking and added setting for output directory.
53
        QTimer       m_timer;
16 by Nathan Osman
Moved some common networking code to defaults.h/cpp and increased the default broadcast timeout to 8 seconds.
54
        QHostAddress m_broadcast_address;
44 by Nathan Osman
Added intelligent timestamp monitoring to prevent excessive notifications when a PC joins an already busy network.
55
        qint64       m_start_time;
15 by Nathan Osman
Added option for specifying timeout interval and modified the format of packets slightly.
56
74 by Nathan Osman
Switched from using the hostname in the machine map to using a uniquely generated UUID to identify each machine.
57
        MachineMap m_machines;
4 by Nathan Osman
Added initial IP multicast code.
58
};
59
60
#endif // CBROADCASTSERVER_H