~mateo-salta/nitroshare/nitroshare

« back to all changes in this revision

Viewing changes to src/discovery/CBroadcastServer.cpp

  • Committer: Nathan Osman
  • Date: 2012-06-28 17:51:28 UTC
  • Revision ID: admin@quickmediasolutions.com-20120628175128-r3r7rbswom1nds5u
Created an intermediate class, CBasicBroadcastServer, which will receive most of the functionality that CBroadcastServer currently has.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    /* Attempt to find the broadcast address on the default address. */
42
42
    if(!Network::FindIPv4Address(Network::GetCurrentInterface(), Network::BroadcastAddress, &m_broadcast_address))
43
43
    {
44
 
        if(Settings::Notify("Error"))
45
 
            emit Message(tr("Unable to find an IPv4 broadcast address for the current interface."), QSystemTrayIcon::Critical);
46
 
 
 
44
        emit Error(tr("Unable to find an IPv4 broadcast address for the current interface."));
47
45
        return;
48
46
    }
49
47
 
50
48
    if(!bind(Settings::Get("Network/BroadcastPort").toUInt(), QUdpSocket::ShareAddress))
51
49
    {
52
 
        if(Settings::Notify("Error"))
53
 
            emit Message(tr("Unable to listen for broadcast notifications."), QSystemTrayIcon::Critical);
54
 
 
 
50
        emit Error(tr("Unable to listen for broadcast notifications."));
55
51
        return;
56
52
    }
57
53
 
117
113
        /* The new machine tells us what time it joined the network, so we
118
114
           can display a message if the user has enabled it. */
119
115
        if(start_time > m_start_time && Settings::Notify("NewPC"))
120
 
            emit Message(tr("%1 has joined the network.").arg(QString(name)), QSystemTrayIcon::Information);
 
116
            emit Information(tr("%1 has joined the network.").arg(QString(name)));
121
117
    }
122
118
 
123
119
    /* Update our entry for the machine. */
143
139
        if(i.value().last_ping + timeout < current_time)
144
140
        {
145
141
            if(Settings::Notify("PCQuit"))
146
 
                emit Message(tr("%1 has left the network.").arg(QString(i.value().name)),
147
 
                             QSystemTrayIcon::Information);
 
142
                emit Information(tr("%1 has left the network.").arg(QString(i.value().name)));
148
143
 
149
144
            m_machines.remove(i.key());
150
145
        }