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
|
/*
Kopete Oscar Protocol
ssimodifytask.h - Handles all the ssi modification stuff
Copyright (c) 2004 by Kopete Developers <kopete-devel@kde.org>
Based on code Copyright (c) 2004 SuSE Linux AG <http://www.suse.com>
Based on Iris, Copyright (C) 2003 Justin Karneges
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 SSIMODIFYTASK_H
#define SSIMODIFYTASK_H
#include "task.h"
#include "oscartypes.h"
#include "ssimanager.h"
class Buffer;
/**
This class takes care of any SSI list modifications that need to be made. This includes:
@li adds
@li edits
@li removes
@li group changes
@li alias changes
@li authorization changes
etc.
This task implements the following SNACs from the SSI family (0x0013):
@li 0x0008
@li 0x0009
@li 0x000A
@li 0x000E
@li 0x0011
@li 0x0012
@author Matt Rogers
*/
class SSIModifyTask : public Task
{
public:
SSIModifyTask( Task* parent, bool staticTask = false );
~SSIModifyTask();
virtual void onGo();
virtual bool take( Transfer* transfer );
/* Contact properties */
enum OperationType { NoType = 0x00, Add = 0x10, Remove = 0x20, Rename = 0x40, Change = 0x80 };
enum OperationSubject { NoSubject = 0x000, Contact = 0x100, Group = 0x200, Visibility = 0x400, Invisibility = 0x800 };
//! Set up the stuff needed to add a contact.
//! @return true if we can send the packet
bool addContact( const TQString& contact, const TQString& group, bool requiresAuth = false );
//! Set up the stuff needed to remove a contact.
//! @return true if we can send the packet
bool removeContact( const TQString& contact );
//! Set up the stuff needed to change groups
//! @return true if we can send the packet
bool changeGroup( const TQString& contact, const TQString& newGroup );
/* Group properties */
//! Add a new group to the SSI list
//! @return true if we can send the packet
bool addGroup( const TQString& groupName );
//! Remove a group from the SSI list
//! @return true if we can send the packet
bool removeGroup( const TQString& groupName );
//! Rename a group on the SSI list
//! @return true if we can send the packet
bool renameGroup( const TQString& oldName, const TQString& newName );
//! Add an item to the SSI list
//! Should be used for other items we don't have explicit functions for
//! like icon hashs, privacy settings, non-icq contacts, etc.
bool addItem( const SSI& item );
//! Remove an item from the SSI list
//! Should be used for other items we don't have explicit functions for
//! like icon hashs, privacy settings, non-icq contacts, etc.
bool removeItem( const SSI& item );
//! Modify an item on the SSI list
//! Should be used for other items we don't have explicit functions for
//! like icon hashs, privacy settings, non-icq contacts, etc.
bool modifyItem( const SSI& oldItem, const SSI& newItem );
protected:
virtual bool forMe( const Transfer* transfer ) const;
private:
//! Handle the acknowledgement from the server
void handleSSIAck();
//! Construct and send the packet to send to the server
void sendSSIUpdate();
//! Helper function to change the group on the server
void changeGroupOnServer();
//! Update the SSI Manager with the new data
void updateSSIManager();
//! Helper function to free id on error
void freeIdOnError();
//! Send the SSI edit start packet
void sendEditStart();
//! Send the SSI edit end packet
void sendEditEnd();
void addItemToBuffer( Oscar::SSI item, Buffer* buffer );
Oscar::SSI getItemFromBuffer( Buffer* buffer ) const;
//! Handle server request to add item
void handleSSIAdd();
//! Handle server request to update item
void handleSSIUpdate();
//! Handle server request to remove item
void handleSSIRemove();
private:
SSI m_oldItem;
SSI m_newItem;
SSI m_groupItem;
OperationType m_opType;
OperationSubject m_opSubject;
WORD m_id;
SSIManager* m_ssiManager;
bool m_static;
};
#endif
|