1 #import <Cocoa/Cocoa.h>
4 #include "ECTagTypes.h"
6 @interface ECTag
: NSObject
{
12 NSMutableArray
*m_subtags
;
15 + (id
)tagFromBuffer
:(uint8_t **) buffer withLenght
:(int) length
;
16 + (NSMutableArray
*)readSubtags
:(uint8_t **) buffer withLenght
:(int) length
;
19 - (void)writeToSocket
:(NSOutputStream
*) socket
;
20 - (void)writeSubtagsToSocket
:(NSOutputStream
*) socket
;
25 - (id
)tagByName
:(ECTagNames
) tagname
;
27 - (uint64_t)tagInt64ByName
:(ECTagNames
) tagname
;
29 @
property (readonly
) ECTagTypes tagType
;
30 @
property (readonly
) ECTagNames tagName
;
32 // needed for fast enumeration of subtags in data updates
33 @
property (readonly
) NSMutableArray
*subtags
;
37 @interface ECTagInt8
: ECTag
{
41 + (id
)tagFromInt8
:(uint8_t) value withName
:(ECTagNames
) name
;
42 + (id
)tagFromBuffer
:(uint8_t **) buffer
;
44 @
property (readonly
)uint8_t uint8Value
;
48 @interface ECTagInt16
: ECTag
{
52 + (id
)tagFromInt16
:(uint16_t) value withName
:(ECTagNames
) name
;
53 + (id
)tagFromBuffer
:(uint8_t **) buffer
;
55 @
property (readonly
)uint16_t uint16Value
;
59 @interface ECTagInt32
: ECTag
{
63 + (id
)tagFromInt32
:(uint32_t) value withName
:(ECTagNames
) name
;
64 + (id
)tagFromBuffer
:(uint8_t **) buffer
;
66 @
property (readonly
)uint32_t uint32Value
;
70 @interface ECTagInt64
: ECTag
{
74 + (id
)tagFromInt64
:(uint64_t) value withName
:(ECTagNames
) name
;
75 + (id
)tagFromBuffer
:(uint8_t **) buffer
;
77 @
property (readonly
)uint64_t uint64Value
;
81 @interface ECTagData
: ECTag
{
85 - (void)writeToSocket
:(NSOutputStream
*) socket
;
86 + (id
)tagFromBuffer
:(uint8_t **) buffer withLenght
:(int) length
;
94 @interface ECTagMD5
: ECTagData
{
95 // contain either raw data (in case of hashed string) or 2 64-bit words (in case of tag coming from ec)
99 + (id
)tagFromString
:(NSString
*) string withName
:(ECTagNames
) name
;
100 + (id
)tagFromBuffer
:(uint8_t **) buffer
;
102 - (MD5Data
)getMD5Data
;
103 - (NSString
*)stringKey
;
107 @interface ECTagString
: ECTagData
{
112 + tagFromString
:(NSString
*) string withName
:(ECTagNames
) name
;
113 + (id
)tagFromBuffer
:(uint8_t **) buffer
;
115 @
property (readonly
) NSString
* stringValue
;
119 @interface ECPacket
: ECTag
{
120 ec_opcode_t m_opcode
;
124 + (id
)packetWithOpcode
:(ec_opcode_t
) opcode
;
125 + (id
)packetFromBuffer
:(uint8_t *) buffer withLength
:(int)length
;
127 - (void)initWithOpcode
:(ec_opcode_t
) opcode
;
129 - (void)writeToSocket
:(NSOutputStream
*) socket
;
131 @
property (readonly
) ec_opcode_t opcode
;
135 @interface ECLoginAuthPacket
: ECPacket
{
138 + (id
)loginPacket
:(NSString
*) password withSalt
:(uint64_t) salt
;
140 - (NSString
*)getMD5_Str
:(NSString
*) str
;
144 @interface ECLoginRequestPacket
: ECPacket
148 + (id
)loginPacket
:(NSString
*) version
;
153 @
class ECRemoteConnection
;
155 @interface amuleLoginHandler
: NSObject
{
156 enum LOGIN_REQUEST_STATE
{
163 ECRemoteConnection
*m_connection
;
168 + (id
)initWithConnection
:(ECRemoteConnection
*) connection
;
170 - (void)handlePacket
:(ECPacket
*) packet
;
172 - (void)usePass
:(NSString
*) pass
;
180 @interface
NSObject (ECRemoteConnection
)
181 - (void)handlePacket
:(ECPacket
*) packet
;
184 @interface ECRemoteConnection
: NSObject
{
185 NSInputStream
*m_istream
;
186 NSOutputStream
*m_ostream
;
188 NSMutableData
*m_rxbuf
;
191 int m_remaining_size
;
198 amuleLoginHandler
*m_login_handler
;
205 + (id
)remoteConnection
;
207 - (void)stream
:(NSStream
*)stream handleEvent
:(NSStreamEvent
)eventCode
;
209 - (void)connectToAddress
:(NSString
*) hostname withPort
:(int)trgport
;
210 - (void)sendLogin
:(NSString
*) password
;
212 - (void)sendPacket
:(ECPacket
*) packet
;
214 @
property (readonly
) bool error
;
216 - (void)setDelegate
:(id
) val
;