-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
209 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
20 changes: 20 additions & 0 deletions
20
quassel-for-ios/quassel-for-ios/QuasselBackgroundFetcher.h
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,20 @@ | ||
// | ||
// QuasselBackgroundFetcher.h | ||
// quassel-for-ios | ||
// | ||
// Created by Markus Goetz on 17.04.20. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "QuasselCoreConnection.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface QuasselBackgroundFetcher : NSObject <QuasselCoreConnectionDelegate> | ||
|
||
- (id) initWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler; | ||
- (void) connectTo:(NSString*)hostName port:(int)port userName:(NSString*)userName passWord:(NSString*)passWord; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
110 changes: 110 additions & 0 deletions
110
quassel-for-ios/quassel-for-ios/QuasselBackgroundFetcher.m
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,110 @@ | ||
// | ||
// QuasselBackgroundFetcher.m | ||
// quassel-for-ios | ||
// | ||
// Created by Markus Goetz on 17.04.20. | ||
// | ||
|
||
#import "QuasselBackgroundFetcher.h" | ||
|
||
@interface QuasselBackgroundFetcher () | ||
@property (strong, nonatomic) QuasselCoreConnection *quasselCoreConnection; | ||
@property (strong, nonatomic) void (^fetchCompletionHandler)(UIBackgroundFetchResult r); | ||
|
||
@end | ||
|
||
@implementation QuasselBackgroundFetcher | ||
{ | ||
} | ||
|
||
- (id) initWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler | ||
{ | ||
self = [super init]; | ||
|
||
self.fetchCompletionHandler = completionHandler; | ||
|
||
self.quasselCoreConnection = [[QuasselCoreConnection alloc] init]; | ||
self.quasselCoreConnection.delegate = self; | ||
|
||
return self; | ||
} | ||
|
||
- (void) connectTo:(NSString*)hostName port:(int)port userName:(NSString*)userName passWord:(NSString*)passWord | ||
{ | ||
[self.quasselCoreConnection connectTo:hostName port:port userName:userName passWord:passWord]; | ||
} | ||
|
||
- (void)quasselAllNetworkInitReceived { | ||
NSLog(@"quasselAllNetworkInitReceived"); | ||
} | ||
|
||
- (void)quasselAuthenticated { | ||
NSLog(@"quasselAuthenticated"); | ||
} | ||
|
||
- (void)quasselBufferListReceived { | ||
NSLog(@"quasselBufferListReceived"); | ||
} | ||
|
||
- (void)quasselBufferListUpdated { | ||
NSLog(@"quasselBufferListUpdated"); | ||
} | ||
|
||
- (void)quasselConnected { | ||
NSLog(@"quasselConnected"); | ||
} | ||
|
||
- (void)quasselEncrypted { | ||
NSLog(@"quasselEncrypted"); | ||
} | ||
|
||
- (void)quasselLastSeenMsgUpdated:(MsgId *)messageId forBuffer:(BufferId *)bufferId { | ||
|
||
} | ||
|
||
- (void)quasselMessageReceived:(Message *)msg received:(enum ReceiveStyle)style onIndex:(int)i { | ||
|
||
} | ||
|
||
- (void)quasselMessagesReceived:(NSArray *)messages received:(enum ReceiveStyle)style { | ||
|
||
} | ||
|
||
- (void)quasselNetworkInitReceived:(NSString *)networkName { | ||
|
||
} | ||
|
||
- (void)quasselNetworkNameUpdated:(NetworkId *)networkId { | ||
|
||
} | ||
|
||
- (void)quasselSocketDidDisconnect:(NSString *)msg { | ||
if (self.fetchCompletionHandler) { | ||
self.fetchCompletionHandler(UIBackgroundFetchResultFailed); | ||
} | ||
} | ||
|
||
- (void)quasselSocketFailedConnect:(NSString *)msg { | ||
self.fetchCompletionHandler(UIBackgroundFetchResultFailed); | ||
self.fetchCompletionHandler = nil; | ||
} | ||
|
||
- (void)quasselSwitchToBuffer:(BufferId *)bufferId { | ||
|
||
} | ||
|
||
- (void) quasselFullyConnected { | ||
NSLog(@"Fully connected"); | ||
int unreadCount = [self.quasselCoreConnection computeUnreadCountForAllBuffers];// computeRelevantUnreadCount | ||
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:unreadCount]; // FIXME only relevant buffers | ||
NSLog(@"%d", unreadCount); | ||
if (unreadCount > 0) { | ||
self.fetchCompletionHandler(UIBackgroundFetchResultNewData); | ||
self.fetchCompletionHandler = nil; | ||
} else { | ||
self.fetchCompletionHandler(UIBackgroundFetchResultNoData); | ||
self.fetchCompletionHandler = nil; | ||
} | ||
|
||
} | ||
@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