forked from ttscoff/nv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimplenoteSession.h
127 lines (93 loc) · 4.47 KB
/
SimplenoteSession.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//
// SimplenoteSession.h
// Notation
//
// Created by Zachary Schneirov on 12/4/09.
/*Copyright (c) 2010, Zachary Schneirov. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials provided with
the distribution.
- Neither the name of Notational Velocity nor the names of its contributors may be used to endorse
or promote products derived from this software without specific prior written permission. */
#import <Cocoa/Cocoa.h>
#import "SyncResponseFetcher.h"
#import "SyncServiceSessionProtocol.h"
#include <SystemConfiguration/SystemConfiguration.h>
@class NoteObject;
@class DeletedNoteObject;
@class NotationPrefs;
@class SimplenoteEntryCollector;
extern NSString *SimplenoteServiceName;
extern NSString *SimplenoteSeparatorKey;
@interface SimplenoteSession : NSObject <SyncServiceSession, NSCopying> {
NSString *emailAddress, *password, *authToken;
CFAbsoluteTime lastSyncedTime;
BOOL lastIndexAuthFailed, reachabilityFailed;
NSString *lastErrorString;
SCNetworkReachabilityRef reachableRef;
SyncResponseFetcher *loginFetcher, *listFetcher;
//used for scheduling mutations:
//e.g., controlling whether a given note should be scheduled
NSTimer *pushTimer;
NSCountedSet *notesToSuppressPushing;
NSMutableSet *unsyncedServiceNotes;
//used for per-note queuing of mutations:
//e.g., ensuring that multiple modifications affecting the same note do not occur simultaneously
//modifications to notes contained in notesBeingModified should be added to queuedNoteInvocations
NSMutableSet *notesBeingModified;
NSMutableDictionary *queuedNoteInvocations;
NSMutableSet *collectorsInProgress;
//used to span multiple partial index fetches (when mark is present in response)
NSMutableArray *indexEntryBuffer;
NSString *indexMark;
id delegate;
}
- (id)initWithNotationPrefs:(NotationPrefs*)prefs;
+ (NSString*)localizedServiceTitle;
+ (NSString*)serviceName;
+ (NSString*)nameOfKeyElement;
+ (NSURL*)servletURLWithPath:(NSString*)path parameters:(NSDictionary*)params;
+ (SCNetworkReachabilityRef)createReachabilityRefWithCallback:(SCNetworkReachabilityCallBack)callout target:(id)aTarget;
//+ (NSString*)localizedNetworkDiagnosticMessage;
- (void)invalidateReachabilityRefs;
- (BOOL)reachabilityFailed;
- (NSComparisonResult)localEntry:(NSDictionary*)localEntry compareToRemoteEntry:(NSDictionary*)remoteEntry;
-(void)applyMetadataUpdatesToNote:(id <SynchronizedNote>)aNote localEntry:(NSDictionary *)localEntry remoteEntry: (NSDictionary *)remoteEntry;
- (BOOL)remoteEntryWasMarkedDeleted:(NSDictionary*)remoteEntry;
- (BOOL)entryHasLocalChanges:(NSDictionary*)entry;
- (BOOL)tagsShouldBeMergedForEntry:(NSDictionary*)entry;
+ (void)registerLocalModificationForNote:(id <SynchronizedNote>)aNote;
- (void)schedulePushForNote:(id <SynchronizedNote>)aNote;
- (void)handleSyncServiceChanges:(NSTimer*)aTimer;
- (BOOL)pushSyncServiceChanges;
- (void)stop;
- (NSSet*)activeTasks;
- (NSString*)lastError;
- (void)clearErrors;
- (BOOL)isRunning;
- (BOOL)hasUnsyncedChanges;
- (id)initWithUsername:(NSString*)aUserString andPassword:(NSString*)aPassString;
- (void)setDelegate:(id)aDelegate;
- (id)delegate;
- (SyncResponseFetcher*)loginFetcher;
- (SyncResponseFetcher*)listFetcher;
- (void)_stoppedWithErrorString:(NSString*)aString;
- (void)_updateSyncTime;
- (void)_clearAuthTokenAndDependencies;
- (BOOL)_checkToken;
- (NSArray*)_notesWithEntries:(NSArray*)entries;
- (NSMutableDictionary*)_invertedContentHashesOfNotes:(NSArray*)notes withSeparator:(NSString*)sep;
- (void)_registerCollector:(SimplenoteEntryCollector*)collector;
- (void)_unregisterCollector:(SimplenoteEntryCollector*)collector;
- (void)_queueInvocation:(NSInvocation*)anInvocation forNote:(id<SynchronizedNote>)aNote;
- (NSInvocation*)_popNextInvocationForNote:(id<SynchronizedNote>)aNote;;
- (void)_modifyNotes:(NSArray*)notes withOperation:(SEL)opSEL;
- (void)startCollectingAddedNotesWithEntries:(NSArray*)entries mergingWithNotes:(NSArray*)notesToMerge;
- (void)startCollectingChangedNotesWithEntries:(NSArray*)entries;
- (BOOL)startFetchingListForFullSyncManual;
- (BOOL)startFetchingListForFullSync;
@end