summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/oscar/liboscar/oscartypeclasses.h
blob: dec69c373194f4696a55fc5d90e0fa506e70dcd7 (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
/*
    Kopete Oscar Protocol
    oscartypeclasses.h - Oscar Type Definitions

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

    Kopete (c) 2002-2004 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 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 _OSCARTYPECLASSES_H_
#define _OSCARTYPECLASSES_H_

#include <tqglobal.h>
#include <tqstring.h>
#include <tqcstring.h>
#include <tqvaluelist.h>
#include "kopete_export.h"

namespace Oscar
{
class KOPETE_EXPORT TLV
{
public:

	TLV();
	TLV( TQ_UINT16, TQ_UINT16, char* data );
	TLV( TQ_UINT16, TQ_UINT16, const TQByteArray& );
	TLV( const TLV& t );

	operator bool() const;

	TQ_UINT16 type;
	TQ_UINT16 length;
	TQByteArray data;

};

class KOPETE_EXPORT SSI
{
public:
	SSI();
	SSI( const TQString &name, int gid, int bid, int type, const TQValueList<TLV>& tlvlist, int tlvLength = 0 );
	SSI( const SSI& other );

	/** Get the validity of this item */
	bool isValid() const;

	/** \brief The name of this SSI item.
	 * This is usually the screenname, ICQ number, or group name. */
	TQString name() const;

	/** \brief The group id of the SSI item */
	TQ_UINT16 gid() const;

	/** \brief The buddy id of the SSI item */
	TQ_UINT16 bid() const;

	/**
	 * \brief The type of the SSI Item.
	 * see ROSTER_* defines on oscartypes.h
	 * Use a value of 0xFFFF for an SSI item not on the server list
	 */
	TQ_UINT16 type() const;

	/** \brief the TLV list for the item */
	const TQValueList<TLV>& tlvList() const;

	/** \brief Set the TLV list for the item */
	void setTLVList( TQValueList<TLV> );

	/**
	 * \brief Set the length of the TLV list
	 *
	 * This is not the number of items in the list!! It's the aggregation of the
	 * sizes of the TLVs
	 */
	void setTLVListLength( TQ_UINT16 newLength );

	/** \brief Get the TLV list length */
	TQ_UINT16 tlvListLength() const;

	/**
	 * Get the alias for the SSI item
	 * This is TLV 0x0131 in an SSI item
	 */
	TQString alias() const;

	/**
	 * Set the alias for the SSI item
	 * This should be done after a successful modification of the item
	 * on the server
	 */
	void setAlias( const TQString& newAlias );

	/** \brief Indicates we're awaiting authorization from this item */
	bool waitingAuth() const;

	/** Set whether we are waiting authorization or not from this item */
	void setWaitingAuth( bool waiting );

	void setIconHash( TQByteArray hash );

	TQByteArray iconHash() const;

	/** \brief String representation of our SSI object */
	TQString toString() const;

	bool operator==( const SSI& item ) const;
	operator bool() const;

	operator TQByteArray() const;

	void refreshTLVLength();

	//! parse the TLVs checking for aliases and auth and stuff like that
	void checkTLVs();

private:
	TQString m_name;
	int m_gid;
	int m_bid;
	int m_type;
	TQValueList<TLV> m_tlvList;
	int m_tlvLength;
	bool m_waitingAuth;
	TQString m_alias;
	TQByteArray m_hash;
};

}

//kate: indent-mode csands; auto-insert-doxygen on; tab-width 4;

#endif