• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/amule/aMule-2.3.1/platforms/MacOSX/cocoa-mule/
1#import <Cocoa/Cocoa.h>
2
3#include "ECCodes.h"
4#include "ECTagTypes.h"
5
6@interface ECTag : NSObject {
7	ECTagTypes m_type;
8    ECTagNames m_name;
9
10	int m_size;
11
12	NSMutableArray *m_subtags;
13}
14
15+ (id)tagFromBuffer:(uint8_t **) buffer withLenght:(int) length;
16+ (NSMutableArray *)readSubtags:(uint8_t **) buffer withLenght:(int) length;
17
18- (void)initSubtags;
19- (void)writeToSocket:(NSOutputStream *) socket;
20- (void)writeSubtagsToSocket:(NSOutputStream *) socket;
21
22- (int)getSize;
23- (int)tagCount;
24
25- (id)tagByName:(ECTagNames) tagname;
26
27- (uint64_t)tagInt64ByName:(ECTagNames) tagname;
28
29@property (readonly) ECTagTypes tagType;
30@property (readonly) ECTagNames tagName;
31
32// needed for fast enumeration of subtags in data updates
33@property (readonly) NSMutableArray *subtags;
34
35@end
36
37@interface ECTagInt8 : ECTag {
38	uint8_t m_val;
39}
40
41+ (id)tagFromInt8:(uint8_t) value withName:(ECTagNames) name;
42+ (id)tagFromBuffer:(uint8_t **) buffer;
43
44@property (readonly)uint8_t uint8Value;
45
46@end
47
48@interface ECTagInt16 : ECTag {
49	uint16_t m_val;
50}
51
52+ (id)tagFromInt16:(uint16_t) value withName:(ECTagNames) name;
53+ (id)tagFromBuffer:(uint8_t **) buffer;
54
55@property (readonly)uint16_t uint16Value;
56
57@end
58
59@interface ECTagInt32 : ECTag {
60	uint32_t m_val;
61}
62
63+ (id)tagFromInt32:(uint32_t) value withName:(ECTagNames) name;
64+ (id)tagFromBuffer:(uint8_t **) buffer;
65
66@property (readonly)uint32_t uint32Value;
67
68@end
69
70@interface ECTagInt64 : ECTag {
71	uint64_t m_val;
72}
73
74+ (id)tagFromInt64:(uint64_t) value withName:(ECTagNames) name;
75+ (id)tagFromBuffer:(uint8_t **) buffer;
76
77@property (readonly)uint64_t uint64Value;
78
79@end
80
81@interface ECTagData : ECTag {
82	NSData *m_data;
83}
84
85- (void)writeToSocket:(NSOutputStream *) socket;
86+ (id)tagFromBuffer:(uint8_t **) buffer withLenght:(int) length;
87
88@end
89
90typedef struct {
91	uint64_t lo, hi;
92} MD5Data;
93
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)
96	MD5Data m_val;
97}
98
99+ (id)tagFromString:(NSString *) string withName:(ECTagNames) name;
100+ (id)tagFromBuffer:(uint8_t **) buffer;
101
102- (MD5Data)getMD5Data;
103- (NSString *)stringKey;
104
105@end
106
107@interface ECTagString : ECTagData {
108	// string
109	NSString *m_val;
110}
111
112+ tagFromString:(NSString *) string withName:(ECTagNames) name;
113+ (id)tagFromBuffer:(uint8_t **) buffer;
114
115@property (readonly) NSString * stringValue;
116
117@end
118
119@interface ECPacket : ECTag {
120	ec_opcode_t m_opcode;
121	uint32_t m_flags;
122}
123
124+ (id)packetWithOpcode:(ec_opcode_t) opcode;
125+ (id)packetFromBuffer:(uint8_t *) buffer withLength:(int)length;
126
127- (void)initWithOpcode:(ec_opcode_t) opcode;
128
129- (void)writeToSocket:(NSOutputStream *) socket;
130
131@property (readonly) ec_opcode_t opcode;
132
133@end
134
135@interface ECLoginAuthPacket : ECPacket {
136}
137
138+ (id)loginPacket:(NSString *) password withSalt:(uint64_t) salt;
139
140- (NSString *)getMD5_Str:(NSString *) str;
141
142@end
143
144@interface ECLoginRequestPacket : ECPacket
145{
146}
147
148+ (id)loginPacket:(NSString *) version;
149
150
151@end
152
153@class ECRemoteConnection;
154
155@interface amuleLoginHandler : NSObject {
156	enum LOGIN_REQUEST_STATE {
157		LOGIN_IDLE,
158		LOGIN_REQUEST_SENT,
159		LOGIN_PASS_SENT,
160		LOGIN_OK
161	} m_state;
162
163	ECRemoteConnection *m_connection;
164
165	NSString *m_pass;
166}
167
168+ (id)initWithConnection:(ECRemoteConnection *) connection;
169
170- (void)handlePacket:(ECPacket *) packet;
171
172- (void)usePass:(NSString *) pass;
173
174- (void)reset;
175- (bool)loginOK;
176
177@end
178
179
180@interface NSObject (ECRemoteConnection)
181- (void)handlePacket:(ECPacket *) packet;
182@end
183
184@interface ECRemoteConnection : NSObject {
185	NSInputStream *m_istream;
186	NSOutputStream *m_ostream;
187
188	NSMutableData *m_rxbuf;
189
190	int m_rx_size;
191	int m_remaining_size;
192
193
194	NSData *m_txbuf;
195	int m_tx_ptr;
196	int m_tx_size;
197
198	amuleLoginHandler *m_login_handler;
199
200    id delegate;
201
202	bool m_error;
203}
204
205+ (id)remoteConnection;
206
207- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode;
208
209- (void)connectToAddress:(NSString *) hostname withPort:(int)trgport;
210- (void)sendLogin:(NSString *) password;
211
212- (void)sendPacket:(ECPacket *) packet;
213
214@property (readonly) bool error;
215
216- (void)setDelegate:(id) val;
217- (id)delegate;
218
219@end
220