summaryrefslogtreecommitdiffstats
path: root/kopete/plugins/smpppdcs/smpppdsearcher.h
blob: 36c4ac9cb6c1edab5df79969cc2092c6d5a3106a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
    smpppdsearcher.h
 
    Copyright (c) 2004-2006 by Heiko Schaefer        <heiko@rangun.de>
 
    Kopete    (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
 
    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; version 2 of the License.               *
    *                                                                       *
    *************************************************************************
*/


#ifndef SMPPPDSEARCHER_H
#define SMPPPDSEARCHER_H

#include <kresolver.h>

class KProcess;

/**
 * @brief Searches a network for a smpppd
 *
 * @todo Use of the SLP to find the smpppd
 * @author Heiko Sch&auml;fer <heiko@rangun.de>
 */
class SMPPPDSearcher : public TQObject {
    Q_OBJECT
  

    SMPPPDSearcher(const SMPPPDSearcher&);
    SMPPPDSearcher& operator=(const SMPPPDSearcher&);

public:
    /**
     * @brief Creates an <code>SMPPPDSearcher</code> instance
     */
    SMPPPDSearcher();
	
    /**
     * @brief Destroys an <code>SMPPPDSearcher</code> instance
     */
    ~SMPPPDSearcher();

    /**
     * @brief Triggers a network scan to find a smpppd
	 * @see smpppdFound
	 * @see smpppdNotFound
     */
    void searchNetwork();
	
	void cancelSearch();

protected:
    /**
     * @brief Scans a network for a smpppd
	 *
	 * Scans a network for a smpppd described by
	 * ip and mask.
	 *
     * @param ip   the ntwork ip
     * @param mask the network mask
     * @return <code>TRUE</code> if an smpppd was found
     */
    bool scan(const TQString& ip, const TQString& mask);

signals:
    /**
     * @brief A smppd was found
	 * 
     * @param host the host there the smpppd was found
     */
    void smpppdFound(const TQString& host);
	
    /**
     * @brief No smpppd was found 
     */
    void smpppdNotFound();
	
	void scanStarted(uint total);
	void scanProgress(uint cur);
	void scanFinished();

protected slots:
    void slotStdoutReceivedIfconfig(KProcess * proc, char * buf, int len);
    void slotStdoutReceivedNetstat (KProcess * proc, char * buf, int len);

private:
	bool m_cancelSearchNow;
    KProcess * m_procIfconfig;
    KProcess * m_procNetstat;
};

inline void SMPPPDSearcher::cancelSearch() {
	m_cancelSearchNow = TRUE;
}

#endif