-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MXServerNotices: Add this class to get notices from the user homeserver
- Loading branch information
Showing
9 changed files
with
393 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
Copyright 2018 New Vector Ltd | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
|
||
#import <Foundation/Foundation.h> | ||
#import "MXJSONModel.h" | ||
|
||
|
||
FOUNDATION_EXPORT NSString *const kMXServerNoticeTypeUsageLimitReached; | ||
|
||
/** | ||
* Content of a m.server_notice event message. | ||
*/ | ||
@interface MXServerNoticeContent : MXJSONModel | ||
|
||
/** | ||
The kind of user limit, generally is monthly_active_user. | ||
*/ | ||
@property (nonatomic, readonly ) NSString *limitType; | ||
|
||
/** | ||
An URI to contact the homeserver administrator | ||
*/ | ||
@property (nonatomic, readonly ) NSString *adminContact; | ||
|
||
/** | ||
The notice type. | ||
Like kMXServerNoticeTypeUsageLimitReached. | ||
*/ | ||
@property (nonatomic, readonly ) NSString *serverNoticeType; | ||
|
||
/** | ||
Inidicate if it is a notice for usage limit reached. | ||
*/ | ||
@property (nonatomic, readonly ) BOOL isServerNoticeUsageLimit; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
Copyright 2018 New Vector Ltd | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#import "MXServerNoticeContent.h" | ||
|
||
NSString *const kMXServerNoticeTypeUsageLimitReached = @"m.server_notice.usage_limit_reached"; | ||
|
||
|
||
@implementation MXServerNoticeContent | ||
|
||
+ (id)modelFromJSON:(NSDictionary *)JSONDictionary | ||
{ | ||
MXServerNoticeContent* serverNoticeUsageLimitContent = [MXServerNoticeContent new]; | ||
if (serverNoticeUsageLimitContent) | ||
{ | ||
MXJSONModelSetString(serverNoticeUsageLimitContent->_limitType, JSONDictionary[@"limit_type"]); | ||
MXJSONModelSetString(serverNoticeUsageLimitContent->_adminContact, JSONDictionary[@"admin_contact"]); | ||
MXJSONModelSetString(serverNoticeUsageLimitContent->_serverNoticeType, JSONDictionary[@"server_notice_type"]); | ||
} | ||
|
||
return serverNoticeUsageLimitContent; | ||
} | ||
|
||
- (BOOL)isServerNoticeUsageLimit | ||
{ | ||
return [kMXServerNoticeTypeUsageLimitReached isEqualToString:_serverNoticeType]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
Copyright 2018 New Vector Ltd | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import "MXServerNoticeContent.h" | ||
|
||
@class MXSession; | ||
|
||
@protocol MXServerNoticesDelegate; | ||
|
||
/** | ||
A `MXServerNotices` instance is responsible for listening to messages from the | ||
user homeserver. | ||
It implements https://github.com/matrix-org/matrix-doc/issues/1452.system where | ||
this communication channel is based on system alert rooms and their pinning events. | ||
*/ | ||
@interface MXServerNotices : NSObject | ||
|
||
/** | ||
Create the `MXServerNotices` instance. | ||
@param mxSession the mxSession to the home server. | ||
@return the newly created MXNotification instance. | ||
*/ | ||
- (instancetype)initWithMatrixSession:(MXSession*)mxSession; | ||
|
||
/** | ||
Stop checking homeserver notices. | ||
*/ | ||
- (void)close; | ||
|
||
/** | ||
If not nil, there is an outgoing usage limitation. | ||
*/ | ||
@property (nonatomic, readonly) MXServerNoticeContent *usageLimit; | ||
|
||
/** | ||
The delegate. | ||
*/ | ||
@property (nonatomic, weak) id<MXServerNoticesDelegate> delegate; | ||
|
||
@end | ||
|
||
|
||
#pragma mark - MXServerNoticesDelegate | ||
|
||
/** | ||
Delegate for `MXCall` object | ||
*/ | ||
@protocol MXServerNoticesDelegate <NSObject> | ||
|
||
/** | ||
Tells the delegate that there is a change in server notices | ||
@param serverNotices the instance that changes. | ||
*/ | ||
- (void)serverNoticesDidChangeState:(MXServerNotices *)serverNotices; | ||
|
||
@end |
Oops, something went wrong.