summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/groupwise/gwcontactlist.h
blob: c0f42045a831038be63dadc6a4d35606feb1e945 (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
/*
    gwcontactlist.h - Kopete GroupWise Protocol

    Copyright (c) 2005      SUSE Linux Products GmbH	 	 http://www.suse.com

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

    *************************************************************************
    *                                                                       *
    * This library 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.      *
    *                                                                       *
    *************************************************************************
*/

// GROUPWISE SERVER SIDE CONTACT LIST MODEL

#include <tqobject.h>

#ifndef GW_CONTACTLIST_H
#define GW_CONTACTLIST_H

class GWFolder;
class GWContactInstance;
class GWContactListItem;

typedef TQValueList<GWContactInstance *> GWContactInstanceList;

	/**
	 *  These functions model the server side contact list structure enough to allow Kopete to manipulate it correctly
	 *  In GroupWise, a contactlist is composed of folders, containing contacts.  But the contacts don't record which 
	 *  folders they are in.  Instead, each contact entry represents an instance of that contact within the list.  
	 *  In Kopete's model, this looks like duplicate contacts (illegal), so instead we have unique contacts, 
	 *  each (by way of its metacontact) knowing membership of potentially >1 KopeteGroups.  Contacts contain a list of the 
	 *  server side list instances.  Contact list management operations affect this list, which is updated during every
	 *  operation.  Having this list allows us to update the server side contact list and keep changes synchronised across 
	 *  different clients.
	 *  The list is volatile - it is not stored in stable storage, but is purged on disconnect and recreated at login.
	 */
class GWContactList : public TQObject
{
Q_OBJECT
  
public:
	GWContactList( TQObject * parent );
	GWFolder * addFolder( unsigned int id, unsigned int sequence, const TQString & displayName );
	GWContactInstance * addContactInstance( unsigned int id, unsigned int parent, unsigned int sequence, const TQString & displayName, const TQString & dn );
	GWFolder * findFolderById( unsigned int id );
	GWFolder * findFolderByName( const TQString & name );
	GWContactInstanceList instancesWithDn( const TQString & dn );
	void removeInstance( GWContactListItem * instance );
	void removeInstanceById( unsigned int id );
	int maxSequenceNumber();
	virtual void dump();
	void clear();
	GWFolder * rootFolder;
};

class GWContactListItem : public TQObject
{
Q_OBJECT
  
public:
	GWContactListItem( TQObject * parent, unsigned int theId, unsigned int theSequence, const TQString & theDisplayName );

	unsigned int id;		// OBJECT_ID
	unsigned int sequence;	// SEQUENCE_NUMBER
	TQString displayName;	// DISPLAY_NAME
};

class GWFolder : public GWContactListItem
{
Q_OBJECT
  
public:
	GWFolder( TQObject * parent, unsigned int theId,  unsigned int theSequence, const TQString & theDisplayName );
	virtual void dump( unsigned int depth );
};

class GWContactInstance : public GWContactListItem
{
Q_OBJECT
  
public:
	GWContactInstance( TQObject * parent, unsigned int theId, unsigned int theSequence, const TQString & theDisplayName, const TQString & theDn );
	TQString dn;				// DN
	virtual void dump( unsigned int depth );
};

// END OF SERVER SIDE CONTACT LIST MODEL

#endif