2 * SNAC - Server-based list management
4 * Copyright (C) 2002 Barnaby Gray <barnaby@beedesign.co.uk>.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include "SNAC-base.h"
30 #include "ContactList.h"
31 #include "ContactTree.h"
32 #include "UserInfoBlock.h"
36 // Server-based list stuff (Family 0x0013)
37 const unsigned short SNAC_SBL_Req_Rights
= 0x0002; // Out
38 const unsigned short SNAC_SBL_Rights_Reply
= 0x0003; // In
39 const unsigned short SNAC_SBL_Request_List
= 0x0004; // Out
40 const unsigned short SNAC_SBL_Check_List
= 0x0005; // Out
41 const unsigned short SNAC_SBL_List_From_Server
= 0x0006; // In
42 const unsigned short SNAC_SBL_List_ACK
= 0x0007; // Out
43 const unsigned short SNAC_SBL_Add_Entry
= 0x0008; // Out
44 const unsigned short SNAC_SBL_Update_Entry
= 0x0009; // Out
45 const unsigned short SNAC_SBL_Remove_Entry
= 0x000a; // Out
46 const unsigned short SNAC_SBL_Edit_ACK
= 0x000e; // In
47 const unsigned short SNAC_SBL_List_Unchanged
= 0x000f; // In
48 const unsigned short SNAC_SBL_Begin_Edit
= 0x0011; // Out
49 const unsigned short SNAC_SBL_Commit_Edit
= 0x0012; // Out
50 const unsigned short SNAC_SBL_Request_Auth
= 0x0018; // Out
51 const unsigned short SNAC_SBL_Auth_Request
= 0x0019; // In
52 const unsigned short SNAC_SBL_Authorise
= 0x001a; // Out
53 const unsigned short SNAC_SBL_Auth_Granted
= 0x001b; // In
54 const unsigned short SNAC_SBL_User_Added_You
= 0x001c; // In
56 // ----------------- Server-based Lists (Family 0x0013) SNACs -----------
58 class SBLFamilySNAC
: virtual public SNAC
61 unsigned short Family() const { return SNAC_FAM_SBL
; }
64 // ============================================================================
66 // ============================================================================
68 class SBLRequestRightsSNAC
: public SBLFamilySNAC
, public OutSNAC
71 void OutputBody(Buffer
& b
) const;
74 SBLRequestRightsSNAC();
76 unsigned short Subtype() const { return SNAC_SBL_Req_Rights
; }
79 // ============================================================================
81 // ============================================================================
83 class SBLRightsReplySNAC
: public SBLFamilySNAC
, public InSNAC
86 void ParseBody(Buffer
& b
);
91 unsigned short Subtype() const { return SNAC_SBL_Rights_Reply
; }
94 // ============================================================================
95 // Unconditional SBL list request
96 // ============================================================================
98 class SBLRequestListSNAC
: public SBLFamilySNAC
, public OutSNAC
101 void OutputBody(Buffer
& b
) const;
104 SBLRequestListSNAC();
106 unsigned short Subtype() const { return SNAC_SBL_Request_List
; }
109 // ============================================================================
111 // ============================================================================
113 class SBLListSNAC
: public SBLFamilySNAC
, public InSNAC
117 unsigned short m_size
;
120 void ParseBody(Buffer
& b
);
125 ContactTree
& getContactTree() { return m_tree
; }
126 unsigned short get_size() const { return m_size
; }
128 unsigned short Subtype() const { return SNAC_SBL_List_From_Server
; }
131 // ============================================================================
132 // SBL list received ACK
133 // ============================================================================
135 class SBLListACKSNAC
: public SBLFamilySNAC
, public OutSNAC
138 void OutputBody(Buffer
& b
) const;
143 unsigned short Subtype() const { return SNAC_SBL_List_ACK
; }
146 // ============================================================================
148 // ============================================================================
150 class SBLBeginEditSNAC
: public SBLFamilySNAC
, public OutSNAC
153 void OutputBody(Buffer
& b
) const;
158 unsigned short Subtype() const { return SNAC_SBL_Begin_Edit
; }
161 // ============================================================================
163 // ============================================================================
165 class SBLAddEntrySNAC
: public SBLFamilySNAC
, public OutSNAC
168 std::string m_group_name
;
169 std::list
<ContactRef
> m_buddy_list
;
170 unsigned short m_group_id
;
173 void OutputBody(Buffer
& b
) const;
177 SBLAddEntrySNAC(const ContactList
& l
);
178 SBLAddEntrySNAC(const ContactRef
& c
);
179 SBLAddEntrySNAC(const std::string
&group_name
, unsigned short group_id
);
181 void addBuddy(const ContactRef
& c
);
183 unsigned short Subtype() const { return SNAC_SBL_Add_Entry
; }
186 // ============================================================================
188 // ============================================================================
190 class SBLUpdateEntrySNAC
: public SBLFamilySNAC
, public OutSNAC
193 std::string m_group_name
;
194 unsigned short m_group_id
;
195 std::vector
<unsigned short> m_ids
;
196 const ContactRef
&m_cont
;
199 void OutputBody(Buffer
& b
) const;
202 SBLUpdateEntrySNAC(const std::string
&group_name
,
203 unsigned short group_id
, const std::vector
<unsigned short> &ids
);
205 SBLUpdateEntrySNAC(const ContactRef
&c
);
207 unsigned short Subtype() const { return SNAC_SBL_Update_Entry
; }
210 // ============================================================================
212 // ============================================================================
214 class SBLRemoveEntrySNAC
: public SBLFamilySNAC
, public OutSNAC
217 std::string m_group_name
;
218 std::list
<ContactRef
> m_buddy_list
;
219 unsigned short m_group_id
;
222 void OutputBody(Buffer
& b
) const;
225 SBLRemoveEntrySNAC();
226 SBLRemoveEntrySNAC(const ContactList
& l
);
227 SBLRemoveEntrySNAC(const ContactRef
& c
);
228 SBLRemoveEntrySNAC(const std::string
&group_name
, unsigned short group_id
);
230 unsigned short Subtype() const { return SNAC_SBL_Remove_Entry
; }
233 // ============================================================================
235 // ============================================================================
237 class SBLCommitEditSNAC
: public SBLFamilySNAC
, public OutSNAC
240 void OutputBody(Buffer
& b
) const;
245 unsigned short Subtype() const { return SNAC_SBL_Commit_Edit
; }
248 // ============================================================================
250 // ============================================================================
252 class SBLEditACKSNAC
: public SBLFamilySNAC
, public InSNAC
263 std::vector
<Result
> m_results
;
264 void ParseBody(Buffer
& b
);
269 std::vector
<Result
> getResults() const { return m_results
; }
270 unsigned short Subtype() const { return SNAC_SBL_Edit_ACK
; }
273 // ============================================================================
274 // SBL List Unchanged reply
275 // ============================================================================
277 class SBLListUnchangedSNAC
: public SBLFamilySNAC
, public InSNAC
280 void ParseBody(Buffer
& b
);
283 SBLListUnchangedSNAC();
284 unsigned short Subtype() const { return SNAC_SBL_List_Unchanged
; }