26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
+
+
+
+
|
@interface Tests: OFObject <OFApplicationDelegate>
@end
OF_APPLICATION_DELEGATE(Tests)
@implementation Tests
{
MTXClient *_client;
}
- (void)applicationDidFinishLaunching
{
__auto_type environment = OFApplication.environment;
if (environment[@"OBJMATRIX_USER"] == nil ||
environment[@"OBJMATRIX_PASS"] == nil ||
environment[@"OBJMATRIX_HS"] == nil) {
[of_stderr writeString: @"Please set OBJMATRIX_USER, "
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
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
|
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
+
-
|
homeserver: homeserver
block: ^ (MTXClient *client, id exception) {
if (exception != nil) {
of_log(@"Error logging in: %@", exception);
[OFApplication terminateWithStatus: 1];
}
_client = [client retain];
of_log(@"Logged in client: %@", client);
of_log(@"Logged in client: %@", _client);
[self fetchRoomList];
}];
}
- (void)fetchRoomList
{
[_client asyncFetchRoomList: ^ (OFArray<OFString *> *rooms,
id exception) {
if (exception != nil) {
of_log(@"Failed to fetch room list: %@", exception);
[OFApplication terminateWithStatus: 1];
}
of_log(@"Fetched room list: %@", rooms);
[self logOut];
}];
}
- (void)logOut
{
[client asyncLogOutWithBlock: ^ (id exception) {
if (exception != nil) {
of_log(@"Failed to log out: %@\n", exception);
[OFApplication terminateWithStatus: 1];
}
[_client asyncLogOutWithBlock: ^ (id exception) {
if (exception != nil) {
of_log(@"Failed to log out: %@\n", exception);
[OFApplication terminateWithStatus: 1];
}
of_log(@"Logged out client");
of_log(@"Logged out client");
[OFApplication terminate];
}];
[OFApplication terminate];
}];
}];
}
@end
|