summaryrefslogtreecommitdiffstats
path: root/kopete/plugins/webpresence/webpresenceplugin.h
blob: 020c6b99feadae8f02a7674a45ff4d2b5e104245 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
    webpresenceplugin.h

    Kopete Web Presence plugin

    Copyright (c) 2002,2003 by Will Stephenson <will@stevello.free-online.co.uk>

    Kopete    (c) 2002,2003 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; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#ifndef WEBPRESENCEPLUGIN_H
#define WEBPRESENCEPLUGIN_H

#include <tqvaluestack.h>

#include <tdeio/job.h>

#include "kopetecontact.h"
#include "kopeteonlinestatus.h"

class TQTimer;
class KTempFile;
namespace Kopete { class MetaContact; }
class TDEToggleAction;
class TDEActionCollection;

typedef TQValueList<Kopete::Protocol*> ProtocolList;

class WebPresencePlugin : public Kopete::Plugin
{
	Q_OBJECT
  

private:
	int frequency;
	bool showAddresses;
	bool useImName;
	TQString userName;
	TQString userStyleSheet;
	bool useImagesInHTML;

	// Is set to true when Kopete has notified us
	// that we're about to be unloaded.
	bool shuttingDown;

	enum {
		WEB_HTML,
		WEB_XHTML,
		WEB_XML,
		WEB_CUSTOM,
		WEB_UNDEFINED
	} resultFormatting;

	TQString resultURL;

public:
	WebPresencePlugin( TQObject *parent, const char *name, const TQStringList &args );
	virtual ~WebPresencePlugin();

	virtual void aboutToUnload();

protected slots:
	void loadSettings();
	
	/**
	 * Write a file to the specified location,
	 */
	void slotWriteFile();
	/**
	 * Called when an upload finished, displays error if needed
	 */
	 void slotUploadJobResult( TDEIO::Job * );
	/**
	 * Called to schedule a write, after waiting to see if more changes
	 * occur (accounts tend to change status together)
	 */
	void slotWaitMoreStatusChanges();
	/**
	 * Sets us up to respond to account status changes
	 */
	void listenToAllAccounts();
	/**
	 * Sets us up to respond to a new account
	 */
	void listenToAccount( Kopete::Account* account );

protected:
	/**
	 * Generate the file (HTML, text) to be uploaded
	 */
	KTempFile* generateFile();
	/**
	* Apply named stylesheet to get content and presentation
	*/
	bool transform( KTempFile* src, KTempFile* dest );
	/** 
	 * Helper method, generates list of all IM protocols
	 */
	ProtocolList allProtocols();
	/**
	 * Converts numeric status to a string
	 */
	TQString statusAsString( const Kopete::OnlineStatus &newStatus );
	/**
     * Schedules writes
	 */
	TQTimer* m_writeScheduler;

	// The file to be uploaded to the WWW
	KTempFile *m_output;
};

#endif