47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
}
@implementation MTXClient
+ (instancetype)clientWithUserID: (OFString *)userID
deviceID: (OFString *)deviceID
accessToken: (OFString *)accessToken
homeserver: (OFURL *)homeserver
{
return [[[self alloc] initWithUserID: userID
deviceID: deviceID
accessToken: accessToken
homeserver: homeserver] autorelease];
}
+ (void)logInWithUser: (OFString *)user
password: (OFString *)password
homeserver: (OFURL *)homeserver
block: (mtx_client_login_block_t)block
{
void *pool = objc_autoreleasePoolPush();
validateHomeserver(homeserver);
MTXRequest *request = [MTXRequest
|
>
|
>
>
|
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
|
}
@implementation MTXClient
+ (instancetype)clientWithUserID: (OFString *)userID
deviceID: (OFString *)deviceID
accessToken: (OFString *)accessToken
homeserver: (OFURL *)homeserver
storage: (id <MTXStorage>)storage
{
return [[[self alloc] initWithUserID: userID
deviceID: deviceID
accessToken: accessToken
homeserver: homeserver
storage: storage] autorelease];
}
+ (void)logInWithUser: (OFString *)user
password: (OFString *)password
homeserver: (OFURL *)homeserver
storage: (id <MTXStorage>)storage
block: (mtx_client_login_block_t)block
{
void *pool = objc_autoreleasePoolPush();
validateHomeserver(homeserver);
MTXRequest *request = [MTXRequest
|
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
} @catch (id e) {
block(nil, e);
return;
}
} else
realHomeserver = homeserver;
MTXClient *client = [MTXClient
clientWithUserID: userID
deviceID: deviceID
accessToken: accessToken
homeserver: realHomeserver];
block(client, nil);
}];
objc_autoreleasePoolPop(pool);
}
- (instancetype)initWithUserID: (OFString *)userID
deviceID: (OFString *)deviceID
accessToken: (OFString *)accessToken
homeserver: (OFURL *)homeserver
{
self = [super init];
@try {
validateHomeserver(homeserver);
_userID = [userID copy];
_deviceID = [deviceID copy];
_accessToken = [accessToken copy];
_homeserver = [homeserver copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_userID release];
[_deviceID release];
[_accessToken release];
[_homeserver release];
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
|
|
<
|
|
|
>
>
>
>
|
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
} @catch (id e) {
block(nil, e);
return;
}
} else
realHomeserver = homeserver;
MTXClient *client = [MTXClient clientWithUserID: userID
deviceID: deviceID
accessToken: accessToken
homeserver: realHomeserver
storage: storage];
block(client, nil);
}];
objc_autoreleasePoolPop(pool);
}
- (instancetype)initWithUserID: (OFString *)userID
deviceID: (OFString *)deviceID
accessToken: (OFString *)accessToken
homeserver: (OFURL *)homeserver
storage: (id <MTXStorage>)storage
{
self = [super init];
@try {
validateHomeserver(homeserver);
_userID = [userID copy];
_deviceID = [deviceID copy];
_accessToken = [accessToken copy];
_homeserver = [homeserver copy];
_storage = [storage retain];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
[_userID release];
[_deviceID release];
[_accessToken release];
[_homeserver release];
[_storage release];
[super dealloc];
}
- (OFString *)description
{
return [OFString stringWithFormat:
|