summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/oscar/liboscar/ssimanager.h
blob: 2d8d4fd168c825d854c4c241f0a02d7514d8a373 (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
/*
	Kopete Oscar Protocol
	ssimanager.h - SSI management

	Copyright ( c ) 2004 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
	Copyright ( c ) 2004 Matt Rogers <mattr@kde.org>

	Kopete ( c ) 2002-2004 by the Kopete developers <kopete-devel@kde.org>

	based on ssidata.h and ssidata.cpp ( c ) 2002 Tom Linsky <twl6@po.cwru.edu>

	*************************************************************************
	*                                                                       *
	* This library is free software; you can redistribute it and/or         *
	* modify it under the terms of the GNU Lesser General Public            *
	* License as published by the Free Software Foundation; either          *
	* version 2 of the License, or ( at your option ) any later version.      *
	*                                                                       *
	*************************************************************************
*/

#ifndef SSIMANAGER_H
#define SSIMANAGER_H

#include <tqobject.h>
#include <tqvaluelist.h>

#include "oscartypes.h"
#include "oscartypeclasses.h"

using namespace Oscar;

class SSIManagerPrivate;

/**
SSI management

@author Gustavo Pichorim Boiko
@author Matt Rogers
*/
class KOPETE_EXPORT SSIManager : public TQObject
{
        Q_OBJECT
  TQ_OBJECT
public:
	SSIManager( TQObject* parent = 0, const char* name = 0 );

	~SSIManager();
	
	/** Clear the internal SSI list */
	void clear();
	
	/** Get the next buddy id for an SSI item */
	WORD nextContactId();
	
	/** Get the next group id for an SSI item */
	WORD nextGroupId();

	/** Get the number of items in the SSI list. */
	WORD numberOfItems() const;

	/** Get the timestamp the list was last modified */
	DWORD lastModificationTime() const;

	/** Set the timestamp of the last modification time */
	void setLastModificationTime( DWORD lastTime );

	/** Set the parameters we should use for SSI */
	void setParameters( WORD maxContacts, WORD maxGroups, WORD maxVisible,
	                    WORD maxInvisible, WORD maxIgnore );

	/**
	 * Load an existing list from SSI objects.
	 * The current SSI list will be overwritten and it's contents
	 * replaced with the data from the new list
	 */
	void loadFromExisting( const TQValueList<Oscar::SSI*>& newList );
	
	bool hasItem( const Oscar::SSI& item ) const;

	Oscar::SSI findGroup( const TQString& group ) const;
	Oscar::SSI findGroup( int groupId ) const;
	

	Oscar::SSI findContact( const TQString& contact, const TQString& group ) const;
	Oscar::SSI findContact( const TQString& contact ) const;
	Oscar::SSI findContact( int contactId ) const;
	
	Oscar::SSI findItemForIcon( TQByteArray iconHash ) const;
	Oscar::SSI findItemForIconByRef( int ) const;
	
	Oscar::SSI findItem( const TQString &contact, int type ) const;

	TQValueList<Oscar::SSI> groupList() const;
	TQValueList<Oscar::SSI> contactList() const;
	TQValueList<Oscar::SSI> visibleList() const;
	TQValueList<Oscar::SSI> invisibleList() const;
	TQValueList<Oscar::SSI> contactsFromGroup( const TQString& group ) const;
	TQValueList<Oscar::SSI> contactsFromGroup( int groupId ) const;
	
	Oscar::SSI visibilityItem() const;

	void setListComplete( bool complete );
	bool listComplete() const;

public slots:
	bool newGroup( const Oscar::SSI& group );
	bool updateGroup( const Oscar::SSI& group );
	bool removeGroup( const Oscar::SSI& group );
	bool removeGroup( const TQString& group );

	bool newContact( const Oscar::SSI& contact );
	bool updateContact( const Oscar::SSI& contact );
	bool removeContact( const Oscar::SSI& contact );
	bool removeContact( const TQString& contact );
	
	bool newItem( const Oscar::SSI& item );
	bool updateItem( const Oscar::SSI& item );
	bool removeItem( const Oscar::SSI& item );

	void addID( const Oscar::SSI& item );
	void removeID( const Oscar::SSI& item );

signals:
	
	//! Emitted when we've added a new contact to the list
	void contactAdded( const Oscar::SSI& );
	
	//! Emitted when we've updated a contact in the list
	void contactUpdated( const Oscar::SSI& );
	
	//! Emitted when we've removed a contact from the list
	void contactRemoved( const TQString& contactName );
	
	//! Emitted when we've added a new group to the list
	void groupAdded( const Oscar::SSI& );
	
	//! Emitted when we've updated a group in the list
	void groupUpdated( const Oscar::SSI& );
	
	//! Emitted when we've removed a group from the ssi list
	void groupRemoved( const TQString& groupName );
	
	void modifyError( const TQString& error );
	
private:
	WORD findFreeId( const TQValueList<WORD>& idList, WORD fromId ) const;
		
	SSIManagerPrivate* d;
	Oscar::SSI m_dummyItem;
};

#endif

//kate: tab-width 4; indent-mode csands;