summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/winpopup/libwinpopup/libwinpopup.h
blob: ca7beecfd80f7a6dc81a3418477804b41b354c63 (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
/***************************************************************************
     libwinpopup.h  -  Base class for the WinPopup protocol
                             -------------------
    begin                : Fri Apr 26 2002
    copyright            : (C) 2002 by Gav Wood
    email                : gav@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; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef LIBWINPOPUP_H
#define LIBWINPOPUP_H

//QT includes
#include <tqobject.h>
#include <tqmap.h>
#include <tqstringlist.h>
#include <tqtimer.h>
#include <tqdatetime.h>

// KDE Includes
#include <tdeprocio.h>
#include <tdefileitem.h>

const TQString WP_POPUP_DIR = TQString::fromLatin1("/var/lib/winpopup");

class KDirLister;

typedef TQMap<TQString, TQString> stringMap;

class WorkGroup
{
	TQStringList groupHosts;

public:
	const TQStringList &Hosts() { return groupHosts; }
	void addHosts(const TQStringList &newHosts) { groupHosts = newHosts; }
};

class WinPopupLib : public TQObject
{
	TQ_OBJECT
  

public:
	WinPopupLib(const TQString &smbClient,int groupFreq);
	~WinPopupLib();

	const TQStringList getGroups();
	const TQStringList getHosts(const TQString &Group);
	bool checkHost(const TQString &Name);
	void settingsChanged(const TQString &smbClient, int groupFreq);
	void sendMessage(const TQString &Body, const TQString &Destination);

private:
	bool passedInitialHost;
	TQMap<TQString, WorkGroup> theGroups, currentGroupsMap;
	TQString currentGroup, currentHost;
	TQStringList todo, done, currentHosts;
	stringMap currentGroups;
	TQTimer updateGroupDataTimer;
	TQString smbClientBin;
	int groupCheckFreq;
	KDirLister *dirLister;

	void readMessages(const KFileItemList &items);
	bool checkMessageDir();

private slots:
	void slotUpdateGroupData();
	void startReadProcess(const TQString &Host);
	void slotReadProcessReady(TDEProcIO *r);
	void slotReadProcessExited(TDEProcess *r);
	void slotSendProcessExited(TDEProcess *p);
	void slotStartDirLister();
	void slotListCompleted();
	void slotNewMessages(const KFileItemList &items);

signals:
	void signalNewMessage(const TQString &, const TQDateTime &, const TQString &);
};

#endif