summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/jabber/jabberprotocol.h
blob: 6e647f7441db567407cd3ea3ebb61e1f5b6d39f5 (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
 /*
  * jabberprotocol.h  -  Base class for the Kopete Jabber protocol
  *
  * Copyright (c) 2002-2003 by Till Gerken <till@tantalo.net>
  * Copyright (c) 2002 by Daniel Stone <dstone@kde.org>
  *
  * Kopete    (c) 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 JABBERPROTOCOL_H
#define JABBERPROTOCOL_H

#include <tqstring.h>
#include <tqstringlist.h>
#include <tqmap.h>
#include <tqpixmap.h>
#include <tqmovie.h>
#include <kaction.h>
#include <kpopupmenu.h>

#include "kopetecontact.h"
#include "kopetecontactproperty.h"
#include "kopetemetacontact.h"
#include "kopeteonlinestatus.h"
#include "addcontactpage.h"

#define JABBER_DEBUG_GLOBAL		14130
#define JABBER_DEBUG_PROTOCOL	14131

namespace XMPP
{
	class Resource;
	class Status;
}

class JabberContact;
class dlgJabberStatus;
class dlgJabberSendRaw;
class JabberCapabilitiesManager;

class JabberProtocol:public Kopete::Protocol
{
	Q_OBJECT
  TQ_OBJECT

public:
	/**
	 * Object constructor and destructor
	 */
	 JabberProtocol (TQObject * parent, const char *name, const TQStringList &);
	 ~JabberProtocol ();

	/**
	 * Creates the "add contact" dialog specific to this protocol
	 */
	virtual AddContactPage *createAddContactWidget (TQWidget * parent, Kopete::Account * i);
	virtual KopeteEditAccountWidget *createEditAccountWidget (Kopete::Account * account, TQWidget * parent);
	virtual Kopete::Account *createNewAccount (const TQString & accountId);

	/**
	 * Deserialize contact data
	 */
	virtual Kopete::Contact *deserializeContact (Kopete::MetaContact * metaContact,
									 const TQMap < TQString, TQString > &serializedData, const TQMap < TQString, TQString > &addressBookData);

	enum OnlineStatus { JabberOnline, JabberFreeForChat, JabberAway, JabberXA, JabberDND,
						JabberOffline, JabberInvisible, JabberConnecting };

	const Kopete::OnlineStatus JabberKOSChatty;
	const Kopete::OnlineStatus JabberKOSOnline;
	const Kopete::OnlineStatus JabberKOSAway;
	const Kopete::OnlineStatus JabberKOSXA;
	const Kopete::OnlineStatus JabberKOSDND;
	const Kopete::OnlineStatus JabberKOSOffline;
	const Kopete::OnlineStatus JabberKOSInvisible;
	const Kopete::OnlineStatus JabberKOSConnecting;

	const Kopete::ContactPropertyTmpl propLastSeen;
	const Kopete::ContactPropertyTmpl propAwayMessage;
	const Kopete::ContactPropertyTmpl propFirstName;
	const Kopete::ContactPropertyTmpl propLastName;
	const Kopete::ContactPropertyTmpl propFullName;
	const Kopete::ContactPropertyTmpl propEmailAddress;
	const Kopete::ContactPropertyTmpl propPrivatePhone;
	const Kopete::ContactPropertyTmpl propPrivateMobilePhone;
	const Kopete::ContactPropertyTmpl propWorkPhone;
	const Kopete::ContactPropertyTmpl propWorkMobilePhone;
	const Kopete::ContactPropertyTmpl propNickName;
	const Kopete::ContactPropertyTmpl propSubscriptionStatus;
	const Kopete::ContactPropertyTmpl propAuthorizationStatus;
	const Kopete::ContactPropertyTmpl propAvailableResources;
	const Kopete::ContactPropertyTmpl propVCardCacheTimeStamp;
	const Kopete::ContactPropertyTmpl propPhoto;
	// extra properties to match with vCard
	const Kopete::ContactPropertyTmpl propJid;
	const Kopete::ContactPropertyTmpl propBirthday;
	const Kopete::ContactPropertyTmpl propTimezone;
	const Kopete::ContactPropertyTmpl propHomepage;
	const Kopete::ContactPropertyTmpl propCompanyName;
	const Kopete::ContactPropertyTmpl propCompanyDepartement;
	const Kopete::ContactPropertyTmpl propCompanyPosition;
	const Kopete::ContactPropertyTmpl propCompanyRole;
	const Kopete::ContactPropertyTmpl propWorkStreet;
	const Kopete::ContactPropertyTmpl propWorkExtAddr;
	const Kopete::ContactPropertyTmpl propWorkPOBox;
	const Kopete::ContactPropertyTmpl propWorkCity;
	const Kopete::ContactPropertyTmpl propWorkPostalCode;
	const Kopete::ContactPropertyTmpl propWorkCountry;
	const Kopete::ContactPropertyTmpl propWorkEmailAddress;
	const Kopete::ContactPropertyTmpl propHomeStreet;
	const Kopete::ContactPropertyTmpl propHomeExtAddr;
	const Kopete::ContactPropertyTmpl propHomePOBox;
	const Kopete::ContactPropertyTmpl propHomeCity;
	const Kopete::ContactPropertyTmpl propHomePostalCode;
	const Kopete::ContactPropertyTmpl propHomeCountry;
	const Kopete::ContactPropertyTmpl propPhoneFax;
	const Kopete::ContactPropertyTmpl propAbout;

	/**
	 * This returns our protocol instance
	 */
	static JabberProtocol *protocol ();

	/**
	 * Return whether the protocol supports offline messages.
	 */
	bool canSendOffline() const { return true; }

	/**
	 * Convert an XMPP::Resource status to a Kopete::OnlineStatus
	 */
	Kopete::OnlineStatus resourceToKOS ( const XMPP::Resource &resource );
	
	/**
	 * Convert an online status to a  XMPP::Status
	 */
	XMPP::Status kosToStatus( const Kopete::OnlineStatus & status, const TQString& message=TQString() );

	/**
	 * Return the Entity Capabilities(JEP-0115) manager instance.
	 */
	JabberCapabilitiesManager *capabilitiesManager();

private:
	/*
	 * Singleton instance of our protocol class
	 */
	static JabberProtocol *protocolInstance;

	/**
	 * Unique Instance of the Entity Capabilities(JEP-0115) manager for Kopete Jabber plugin.
	 */
	JabberCapabilitiesManager *capsManager;
};

#endif