adding missing includes; trivial fix - comparison with string literal. by
[centerim.git] / libicq2000 / src / SNAC-SBL.h
blob8213a07d469c98b6751bb286a37b7317e4c2d9e8
1 /*
2 * SNAC - Server-based list management
3 * Mitz Pettel, 2001
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.
22 #ifndef SNAC_SBL_H
23 #define SNAC_SBL_H
25 #include <string>
26 #include <list>
28 #include "SNAC-base.h"
29 #include "Contact.h"
30 #include "ContactList.h"
31 #include "ContactTree.h"
32 #include "UserInfoBlock.h"
34 namespace ICQ2000 {
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
60 public:
61 unsigned short Family() const { return SNAC_FAM_SBL; }
64 // ============================================================================
65 // Request SBL rights
66 // ============================================================================
68 class SBLRequestRightsSNAC : public SBLFamilySNAC, public OutSNAC
70 protected:
71 void OutputBody(Buffer& b) const;
73 public:
74 SBLRequestRightsSNAC();
76 unsigned short Subtype() const { return SNAC_SBL_Req_Rights; }
79 // ============================================================================
80 // SBL rights reply
81 // ============================================================================
83 class SBLRightsReplySNAC : public SBLFamilySNAC, public InSNAC
85 protected:
86 void ParseBody(Buffer& b);
88 public:
89 SBLRightsReplySNAC();
91 unsigned short Subtype() const { return SNAC_SBL_Rights_Reply; }
94 // ============================================================================
95 // Unconditional SBL list request
96 // ============================================================================
98 class SBLRequestListSNAC : public SBLFamilySNAC, public OutSNAC
100 protected:
101 void OutputBody(Buffer& b) const;
103 public:
104 SBLRequestListSNAC();
106 unsigned short Subtype() const { return SNAC_SBL_Request_List; }
109 // ============================================================================
110 // SBL list reply
111 // ============================================================================
113 class SBLListSNAC : public SBLFamilySNAC, public InSNAC
115 private:
116 ContactTree m_tree;
117 unsigned short m_size;
119 protected:
120 void ParseBody(Buffer& b);
122 public:
123 SBLListSNAC();
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
137 protected:
138 void OutputBody(Buffer& b) const;
140 public:
141 SBLListACKSNAC();
143 unsigned short Subtype() const { return SNAC_SBL_List_ACK; }
146 // ============================================================================
147 // SBL Begin Edit
148 // ============================================================================
150 class SBLBeginEditSNAC : public SBLFamilySNAC, public OutSNAC
152 protected:
153 void OutputBody(Buffer& b) const;
155 public:
156 SBLBeginEditSNAC();
158 unsigned short Subtype() const { return SNAC_SBL_Begin_Edit; }
161 // ============================================================================
162 // SBL Add Entry
163 // ============================================================================
165 class SBLAddEntrySNAC : public SBLFamilySNAC, public OutSNAC
167 private:
168 std::string m_group_name;
169 std::list<ContactRef> m_buddy_list;
170 unsigned short m_group_id;
172 protected:
173 void OutputBody(Buffer& b) const;
175 public:
176 SBLAddEntrySNAC();
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 // ============================================================================
187 // SBL Update Entry
188 // ============================================================================
190 class SBLUpdateEntrySNAC : public SBLFamilySNAC, public OutSNAC
192 private:
193 std::string m_group_name;
194 unsigned short m_group_id;
195 std::vector<unsigned short> m_ids;
196 const ContactRef &m_cont;
198 protected:
199 void OutputBody(Buffer& b) const;
201 public:
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 // ============================================================================
211 // SBL Remove Entry
212 // ============================================================================
214 class SBLRemoveEntrySNAC : public SBLFamilySNAC, public OutSNAC
216 private:
217 std::string m_group_name;
218 std::list<ContactRef> m_buddy_list;
219 unsigned short m_group_id;
221 protected:
222 void OutputBody(Buffer& b) const;
224 public:
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 // ============================================================================
234 // SBL Commit Edit
235 // ============================================================================
237 class SBLCommitEditSNAC : public SBLFamilySNAC, public OutSNAC
239 protected:
240 void OutputBody(Buffer& b) const;
242 public:
243 SBLCommitEditSNAC();
245 unsigned short Subtype() const { return SNAC_SBL_Commit_Edit; }
248 // ============================================================================
249 // SBL Edit ACK
250 // ============================================================================
252 class SBLEditACKSNAC : public SBLFamilySNAC, public InSNAC
254 public:
255 enum Result {
256 Success,
257 Failed,
258 AuthRequired,
259 AlreadyExists
262 protected:
263 std::vector<Result> m_results;
264 void ParseBody(Buffer& b);
266 public:
267 SBLEditACKSNAC();
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
279 protected:
280 void ParseBody(Buffer& b);
282 public:
283 SBLListUnchangedSNAC();
284 unsigned short Subtype() const { return SNAC_SBL_List_Unchanged; }
289 #endif