├── IMG_0529.PNG ├── IMG_0530.PNG ├── Makefile ├── OutputSample.txt ├── libnotify.deb ├── libnotify.xm ├── package ├── DEBIAN │ └── control ├── Library │ ├── MobileSubstrate │ │ └── DynamicLibraries │ │ │ └── libnotify.dylib │ └── PreferenceLoader │ │ └── Preferences │ │ └── LibNotifyWatch.plist └── System │ └── Library │ └── PreferenceBundles │ └── LibNotifyWatch.bundle │ ├── BlueCheck.png │ ├── BlueCheck@2x.png │ ├── Info.plist │ ├── LibNotifyWatch │ ├── LibNotifyWatch.plist │ ├── LibNotifyWatch.png │ ├── LibNotifyWatch@2x.png │ ├── WhiteSpace.png │ └── WhiteSpace@2x.png ├── preferenceBundle ├── LibNotifyWatch.mm ├── Makefile ├── Resources │ ├── BlueCheck.png │ ├── BlueCheck@2x.png │ ├── Info.plist │ ├── LibNotify.plist │ ├── LibNotifyWatch │ ├── LibNotifyWatch.plist │ ├── LibNotifyWatch.png │ ├── LibNotifyWatch@2x.png │ ├── WhiteSpace.png │ └── WhiteSpace@2x.png └── entry.plist └── readme.md /IMG_0529.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/IMG_0529.PNG -------------------------------------------------------------------------------- /IMG_0530.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/IMG_0530.PNG -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TWEAK_NAME = libnotify 2 | libnotify_FILES = libnotify.xm 3 | libnotify_LDFLAGS = -lsqlite3 4 | libnotify_FRAMEWORKS = UIKit CoreFoundation 5 | include framework/makefiles/common.mk 6 | include framework/makefiles/tweak.mk 7 | -------------------------------------------------------------------------------- /OutputSample.txt: -------------------------------------------------------------------------------- 1 | Feb 28 00:45:37 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.springboard.orientation 2 | Feb 28 00:45:37 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.springboard.unambiguousOrientation 3 | Feb 28 00:45:37 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.airport.userNotification 4 | Feb 28 00:45:37 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.mobile.SubstantialTransition 5 | Feb 28 00:45:37 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.Preferences-suspended 6 | Feb 28 00:45:37 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.airportsettingsvisible 7 | Feb 28 00:45:49 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.springboard.fullycharged 8 | Feb 28 00:45:51 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.springboard.callinterruptedapp 9 | Feb 28 00:45:51 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.Preferences-activated 10 | Feb 28 00:45:52 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.airport.userNotification 11 | Feb 28 00:45:52 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.mobile.SubstantialTransition 12 | Feb 28 00:45:52 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.springboard.orientation 13 | Feb 28 00:45:52 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.springboard.unambiguousOrientation 14 | Feb 28 00:45:53 Limneos-iPhone4 Preferences[5350]: LibNotifyWatch: notify_post libnotify.prefsChanged 15 | Feb 28 00:45:56 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.springboard.orientation 16 | Feb 28 00:45:56 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.springboard.unambiguousOrientation 17 | Feb 28 00:45:56 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.airport.userNotification 18 | Feb 28 00:45:56 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: CFNotificationCenterPostNotification center= name=com.apple.mobile.SubstantialTransition userInfo=(null) deliverImmediately=0 20 | Feb 28 00:45:56 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.mobile.SubstantialTransition 21 | Feb 28 00:45:56 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: CFNotificationCenterPostNotification center= name=com.apple.Preferences-suspended userInfo=(null) deliverImmediately=1 23 | Feb 28 00:45:56 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.Preferences-suspended 24 | Feb 28 00:45:56 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: notify_post com.apple.airportsettingsvisible 25 | Feb 28 00:45:56 Limneos-iPhone4 SpringBoard[5323]: LibNotifyWatch: CFNotificationCenterPostNotification center= name=BufferBackingWillDeallocate userInfo=(null) deliverImmediately=1 27 | Feb 28 00:47:53 Limneos-iPhone4 MobileSMS[5780]: LibNotifyWatch: SQLITE3_PREPARE_V2 query=SELECT value, record_id, identifier FROM ABMultiValue WHERE 28 | UID IN (SELECT multivalue_id FROM ABPhoneLastFour WHERE value = ? OR value = ? OR value = ? OR value = ? OR value = ? OR value = ? OR value = ? OR 29 | value = ? ); 30 | 31 | -------------------------------------------------------------------------------- /libnotify.deb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/libnotify.deb -------------------------------------------------------------------------------- /libnotify.xm: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #import 6 | #import 7 | 8 | // init define static variables 9 | static BOOL hookNSNotifCenter=1; 10 | static BOOL hookDarwin=1; 11 | static BOOL hookNotifyPost=1; 12 | static BOOL hookCopyAppValue=0; 13 | static BOOL hookSqlite=0; 14 | static BOOL hookCPDistMess=0; 15 | static BOOL hooksEnabled=1; 16 | static NSString *filter=nil; 17 | // end define static variables 18 | 19 | 20 | 21 | // init notify_post hook 22 | static uint32_t (*original_notify_post)(const char *name); 23 | 24 | uint32_t replaced_notify_post(const char *name) { 25 | 26 | if (hookNotifyPost){ 27 | 28 | if (nil != filter){ 29 | 30 | NSString *pSTRING=[[NSString alloc] initWithCString:name]; 31 | NSRange range=[pSTRING rangeOfString:filter options:(NSCaseInsensitiveSearch)]; 32 | [pSTRING release]; 33 | if (range.location!=NSNotFound){ 34 | NSLog(@"LibNotifyWatch: notify_post %s",name); 35 | } 36 | } 37 | else { 38 | NSLog(@"LibNotifyWatch: notify_post %s",name); 39 | } 40 | } 41 | 42 | return original_notify_post(name); 43 | } 44 | // end notify_post hook 45 | 46 | 47 | 48 | 49 | 50 | // init CFPreferencesCopyAppValue hook 51 | static CFPropertyListRef (*orig_CFPreferencesCopyAppValue)(CFStringRef key,CFStringRef applicationID); 52 | 53 | CFPropertyListRef replaced_CFPreferencesCopyAppValue(CFStringRef key,CFStringRef applicationID){ 54 | 55 | if (hookCopyAppValue){ 56 | if (nil != filter){ 57 | CFStringRef searchString=CFStringCreateWithCString(nil, [filter UTF8String], kCFStringEncodingUTF8); 58 | CFRange range1=CFStringFind(key,searchString,kCFCompareCaseInsensitive); 59 | CFRange range2=CFStringFind(applicationID,searchString,kCFCompareCaseInsensitive); 60 | CFRelease(searchString); 61 | if (range1.length>0 || range2.length>0){ 62 | NSLog(@"LibNotifyWatch: CFPreferencesCopyAppValue key=%@ applicationID=%@",key,applicationID); 63 | } 64 | } 65 | else { 66 | NSLog(@"LibNotifyWatch: CFPreferencesCopyAppValue key=%@ applicationID=%@",key,applicationID); 67 | } 68 | } 69 | 70 | return orig_CFPreferencesCopyAppValue(key,applicationID); 71 | 72 | } 73 | // end CFPreferencesCopyAppValue hook 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | // init CFNotificationCenterPostNotification hook 82 | void (*orig_CFNotificationCenterPostNotification) ( 83 | CFNotificationCenterRef center, 84 | CFStringRef name, 85 | const void *object, 86 | CFDictionaryRef userInfo, 87 | Boolean deliverImmediately 88 | ); 89 | 90 | void replaced_CFNotificationCenterPostNotification ( 91 | CFNotificationCenterRef center, 92 | CFStringRef name, 93 | const void *object, 94 | CFDictionaryRef userInfo, 95 | Boolean deliverImmediately 96 | ){ 97 | if (hookDarwin){ 98 | if (nil != filter){ 99 | CFStringRef searchString=CFStringCreateWithCString(nil, [filter UTF8String], kCFStringEncodingUTF8); 100 | CFRange range=CFStringFind(name,searchString,kCFCompareCaseInsensitive); 101 | CFRelease(searchString); 102 | if (range.length>0){ 103 | 104 | NSLog(@"LibNotifyWatch: CFNotificationCenterPostNotification center=%@ name=%@ userInfo=%@ deliverImmediately=%d",center,name,(NSDictionary *)userInfo,deliverImmediately); 105 | } 106 | } 107 | else { 108 | NSLog(@"LibNotifyWatch: CFNotificationCenterPostNotification center=%@ name=%@ userInfo=%@ deliverImmediately=%d",center,name,(NSDictionary *)userInfo,deliverImmediately); 109 | } 110 | } 111 | 112 | orig_CFNotificationCenterPostNotification(center,name,object,userInfo,deliverImmediately); 113 | 114 | } 115 | // end CFNotificationCenterPostNotification hook 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | // init sqlite3_prepare_v2 hook 125 | int (* orig_sqlite3_prepare_v2)( 126 | sqlite3 *db, /* Database handle */ 127 | const char *zSql, /* SQL statement, UTF-8 encoded */ 128 | int nByte, /* Maximum length of zSql in bytes. */ 129 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ 130 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ 131 | ); 132 | 133 | int replaced_sqlite3_prepare_v2( 134 | sqlite3 *db, /* Database handle */ 135 | const char *zSql, /* SQL statement, UTF-8 encoded */ 136 | int nByte, /* Maximum length of zSql in bytes. */ 137 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ 138 | const char **pzTail /* OUT: Pointer to unused portion of zSql */ 139 | ){ 140 | 141 | int res=orig_sqlite3_prepare_v2(db,zSql,nByte,ppStmt,pzTail); 142 | if (hookSqlite){ 143 | if (nil != filter){ 144 | NSString *sqString=[[NSString alloc] initWithCString:zSql ]; 145 | NSRange range=[sqString rangeOfString:filter]; 146 | [sqString release]; 147 | if (range.location!=NSNotFound){ 148 | NSLog(@"LibNotifyWatch: SQLITE3_PREPARE_V2 query=%s ",zSql); 149 | } 150 | } 151 | else{ 152 | NSLog(@"LibNotifyWatch: SQLITE3_PREPARE_V2 query=%s",zSql); 153 | } 154 | } 155 | return res; 156 | } 157 | // end sqlite3_prepare_v2 hook 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | // init NSNotificationCenter hook 167 | %hook NSNotificationCenter 168 | - (void)postNotification:(NSNotification *)notification{ 169 | 170 | if (hookNSNotifCenter && ((filter && [[notification name] rangeOfString:filter].location!=NSNotFound) || !filter) ){ 171 | NSLog(@"LibNotifyWatch: %@ postNotification: %@",self,notification); 172 | } 173 | 174 | %orig; 175 | } 176 | /* 177 | - (void)postNotificationName:(NSString *)aName object:(id)anObject{ 178 | 179 | if (hookNSNotifCenter){ 180 | 181 | if (nil != filter){ 182 | 183 | NSRange range=[aName rangeOfString:filter]; 184 | if (range.location!=NSNotFound){ 185 | NSLog(@"LibNotifyWatch: %@ postNotificationName: %@ object:%@",self,aName,anObject); 186 | } 187 | 188 | } 189 | 190 | else{ 191 | 192 | NSLog(@"LibNotifyWatch: %@ postNotificationName: %@ object:%@",self,aName,anObject); 193 | 194 | } 195 | 196 | } 197 | 198 | %orig; 199 | } 200 | */ 201 | - (void)postNotificationName:(NSString *)aName object:(id)anObject userInfo:(NSDictionary *)aUserInfo{ 202 | 203 | if (hookNSNotifCenter && ((filter && [aName rangeOfString:filter].location!=NSNotFound) || !filter) ){ 204 | 205 | NSLog(@"LibNotifyWatch: %@ postNotificationName:%@ object:%@ userInfo:%@",self,aName,anObject,aUserInfo); 206 | 207 | } 208 | 209 | 210 | %orig; 211 | } 212 | 213 | %end 214 | // end NSNotificationCenter hook 215 | 216 | 217 | %hook CPDistributedMessagingCenter 218 | -(BOOL)sendMessageName:(id)name userInfo:(id)info{ 219 | if (hookCPDistMess && ((filter && [name rangeOfString:filter].location!=NSNotFound) || !filter)){ 220 | NSLog(@"LibNotifyWatch: %@ sendMessageName:%@ userInfo:%@",self,name,info); 221 | } 222 | return %orig; 223 | } 224 | 225 | /* 226 | -(id)sendMessageAndReceiveReplyName:(id)name userInfo:(id)info{ 227 | if (hookCPDistMess){ 228 | NSLog(@"LibNotifyWatch: %@ sendMessageAndReceiveReplyName:%@ userInfo:%@",self,name,info); 229 | } 230 | return %orig; 231 | } 232 | */ 233 | -(id)sendMessageAndReceiveReplyName:(id)name userInfo:(id)info error:(id*)error{ 234 | id result=%orig; 235 | if (hookCPDistMess && ((filter && [name rangeOfString:filter].location!=NSNotFound) || !filter)){ 236 | NSLog(@"LibNotifyWatch: %@ sendMessageAndReceiveReplyName:%@ userInfo:%@ error:na",self,name,info); 237 | } 238 | return result; 239 | } 240 | -(void)sendMessageAndReceiveReplyName:(id)name userInfo:(id)info toTarget:(id)target selector:(SEL)selector context:(void*)context{ 241 | if (hookCPDistMess && ((filter && [name rangeOfString:filter].location!=NSNotFound) || !filter)){ 242 | NSLog(@"LibNotifyWatch: %@ sendMessageAndReceiveReplyName:%@ userInfo:%@ toTarget:%@ selector:%: context",self,name,info,target,selector); 243 | } 244 | %orig; 245 | } 246 | -(BOOL)_sendMessage:(id)message userInfo:(id)info receiveReply:(id*)reply error:(id*)error toTarget:(id)target selector:(SEL)selector context:(void*)context{ 247 | BOOL result=%orig; 248 | if (hookCPDistMess && ((filter && [message rangeOfString:filter].location!=NSNotFound) || !filter)){ 249 | NSLog(@"LibNotifyWatch: %@ _sendMessage:%@ userInfo:%@ receiveReply:na error:na toTarget:%@ selector:%: context",self,message,info,target,selector); 250 | } 251 | return result; 252 | } 253 | -(BOOL)_sendMessage:(id)message userInfoData:(id)data oolKey:(id)key oolData:(id)data4 receiveReply:(id*)reply error:(id*)error{ 254 | BOOL result=%orig; 255 | if (hookCPDistMess && ((filter && [message rangeOfString:filter].location!=NSNotFound) || !filter)){ 256 | NSLog(@"LibNotifyWatch: %@ _sendMessage:%@ userInfoData:na receiveReply:na oolKey:na oolData:na receiveReply:na error:na",self,message); 257 | } 258 | return result; 259 | } 260 | 261 | %end 262 | 263 | 264 | 265 | // Obtain Preferences 266 | static void getPreferences(){ 267 | 268 | NSDictionary *Prefs=[NSDictionary dictionaryWithContentsOfFile:@"/private/var/mobile/Library/Preferences/libnotify.plist"]; 269 | 270 | filter=Prefs!=nil ? ([Prefs objectForKey:@"filter"]!=nil ? (NSString *)[Prefs objectForKey:@"filter"] : nil) : nil; 271 | if ([filter isEqualToString:@""]){ 272 | filter=nil; 273 | } 274 | if (filter){ 275 | [filter retain]; 276 | } 277 | 278 | hooksEnabled=Prefs!=nil ? ([Prefs objectForKey:@"enabled"]!=nil ? [[Prefs objectForKey:@"enabled"] boolValue] : 1) : 1; 279 | if (!hooksEnabled){ 280 | hookNSNotifCenter=0; 281 | hookSqlite=0; 282 | hookDarwin=0; 283 | hookNotifyPost=0; 284 | hookCopyAppValue=0; 285 | hookCPDistMess=0; 286 | return ; 287 | } 288 | 289 | NSMutableArray *functionsArray=(NSMutableArray *)[Prefs objectForKey:@"functions"]; 290 | NSMutableArray *enabledArray=[NSMutableArray array]; 291 | 292 | for (NSDictionary *dict in functionsArray){ 293 | if ([[dict valueForKey:@"Enabled"] boolValue]==YES){ 294 | [enabledArray addObject:[dict valueForKey:@"functionName"]]; 295 | } 296 | } 297 | 298 | hookNSNotifCenter=[enabledArray containsObject:@"NSNotificationCenter"]; 299 | hookSqlite=[enabledArray containsObject:@"Sqlite3 Queries"]; 300 | hookDarwin=[enabledArray containsObject:@"CFNotificationCenter(Darwin)"]; 301 | hookNotifyPost=[enabledArray containsObject:@"notify_post"]; 302 | hookCopyAppValue=[enabledArray containsObject:@"CFPreferencesCopyAppValue"]; 303 | hookCPDistMess=[enabledArray containsObject:@"CPDistributedMessagingCenter"]; 304 | } 305 | 306 | 307 | 308 | // init function to update Preferences on-the-fly 309 | static void updatePrefs(CFNotificationCenterRef center, 310 | void *observer, 311 | CFStringRef name, 312 | const void *object, 313 | CFDictionaryRef userInfo) { 314 | getPreferences(); 315 | } 316 | // end function to update Preferences on-the-fly 317 | 318 | 319 | 320 | // Constructor 321 | __attribute__((constructor)) void libnotifywatchInit() { 322 | 323 | %init; 324 | 325 | NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init]; 326 | 327 | CFNotificationCenterRef notifCenter = CFNotificationCenterGetDarwinNotifyCenter(); 328 | CFNotificationCenterAddObserver(notifCenter, NULL, &updatePrefs, CFSTR("libnotify.prefsChanged"), NULL, 0); 329 | 330 | getPreferences(); 331 | 332 | // replace original functions behavior 333 | MSHookFunction(sqlite3_prepare_v2, replaced_sqlite3_prepare_v2, &orig_sqlite3_prepare_v2); 334 | MSHookFunction((uint32_t *)notify_post, (uint32_t *)replaced_notify_post, (uint32_t **)&original_notify_post); 335 | MSHookFunction(CFPreferencesCopyAppValue, replaced_CFPreferencesCopyAppValue, &orig_CFPreferencesCopyAppValue); 336 | MSHookFunction(CFNotificationCenterPostNotification, replaced_CFNotificationCenterPostNotification, &orig_CFNotificationCenterPostNotification); 337 | 338 | [p drain]; 339 | 340 | } -------------------------------------------------------------------------------- /package/DEBIAN/control: -------------------------------------------------------------------------------- 1 | Package: libnotify 2 | Name: NotifyWatch 3 | Version: 0.1 4 | Architecture: iphoneos-arm 5 | Icon: file:///System/Library/PreferencesBundles/LibNotifyWatch.bundle/LibNotifyWatch.png 6 | Maintainer: Elias Limneos 7 | Depends: mobilesubstrate, preferenceloader, firmware ( >= 4.0 ) 8 | Description: Log system-posted notifications 9 | This tool is intented for developers. 10 | Please do not install unless you know what you're doing. 11 | 12 | This library offers logging of most system notification-posting 13 | functions. 14 | Filtering options and function hooking selection available in settings. 15 | -------------------------------------------------------------------------------- /package/Library/MobileSubstrate/DynamicLibraries/libnotify.dylib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/package/Library/MobileSubstrate/DynamicLibraries/libnotify.dylib -------------------------------------------------------------------------------- /package/Library/PreferenceLoader/Preferences/LibNotifyWatch.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | entry 6 | 7 | bundle 8 | LibNotifyWatch 9 | cell 10 | PSLinkCell 11 | detail 12 | LibNotifyListController 13 | icon 14 | LibNotifyWatch.png 15 | isController 16 | 1 17 | label 18 | LibNotifyWatch 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/BlueCheck.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/BlueCheck.png -------------------------------------------------------------------------------- /package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/BlueCheck@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/BlueCheck@2x.png -------------------------------------------------------------------------------- /package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | LibNotifyWatch 9 | CFBundleIdentifier 10 | libnotify 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.0 21 | DTPlatformName 22 | iphoneos 23 | MinimumOSVersion 24 | 3.0 25 | NSPrincipalClass 26 | LibNotifyListController 27 | 28 | 29 | -------------------------------------------------------------------------------- /package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/LibNotifyWatch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/LibNotifyWatch -------------------------------------------------------------------------------- /package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/LibNotifyWatch.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | PostNotification 9 | libnotify.prefsChanged 10 | cell 11 | PSSwitchCell 12 | default 13 | 14 | defaults 15 | libnotify 16 | key 17 | enabled 18 | label 19 | Enable Logging 20 | 21 | 22 | cell 23 | PSGroupCell 24 | label 25 | Functions To Watch 26 | 27 | 28 | cell 29 | PSLinkListCell 30 | defaults 31 | libnotify 32 | detail 33 | LibNotifyViewController 34 | key 35 | choosefunctions 36 | label 37 | Select Functions 38 | 39 | 40 | cell 41 | PSGroupCell 42 | label 43 | Filter Notifications 44 | 45 | 46 | PostNotification 47 | libnotify.prefsChanged 48 | cell 49 | PSEditTextCell 50 | defaults 51 | libnotify 52 | key 53 | filter 54 | label 55 | Containing string: 56 | 57 | 58 | cell 59 | PSGroupCell 60 | footerText 61 | Logs are written to /var/log/syslog. Make sure syslogd is active 62 | 63 | 64 | cell 65 | PSGroupCell 66 | footerText 67 | Suggested usage: tail -f /var/log/syslog | grep -i libnotifywatch 68 | 69 | 70 | alignment 71 | 0.0 72 | cell 73 | PSGroupCell 74 | label 75 | Warning: Extensive logging can cause lag to your device. Make sure you only use it when you need to. 76 | 77 | 78 | title 79 | LibNotifyWatch 80 | 81 | 82 | -------------------------------------------------------------------------------- /package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/LibNotifyWatch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/LibNotifyWatch.png -------------------------------------------------------------------------------- /package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/LibNotifyWatch@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/LibNotifyWatch@2x.png -------------------------------------------------------------------------------- /package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/WhiteSpace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/WhiteSpace.png -------------------------------------------------------------------------------- /package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/WhiteSpace@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/package/System/Library/PreferenceBundles/LibNotifyWatch.bundle/WhiteSpace@2x.png -------------------------------------------------------------------------------- /preferenceBundle/LibNotifyWatch.mm: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | #import 6 | #import 7 | 8 | 9 | @interface LibNotifyViewController : PSViewController { 10 | UITableView *tblView; 11 | NSMutableArray *functions; 12 | NSMutableDictionary *dict; 13 | NSString *dictPath; 14 | 15 | } 16 | @property (nonatomic, retain) UITableView *tblView; 17 | @property (nonatomic, retain) NSMutableArray *functions; 18 | @property (nonatomic, retain) NSMutableDictionary *dict; 19 | @property (nonatomic, retain) NSString *dictPath; 20 | 21 | 22 | - (id) initForContentSize:(CGSize)size ; 23 | 24 | - (id) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; 25 | - (int) tableView:(UITableView *)tableView numberOfRowsInSection:(int)section; 26 | - (void) dealloc; 27 | - (id) navigationTitle; 28 | - (id) view; 29 | - (int) numberOfSectionsInTableView:(UITableView *)tableView; 30 | @end 31 | 32 | 33 | 34 | @interface LibNotifyController: PSListController { 35 | } 36 | @end 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | @implementation LibNotifyViewController 45 | @synthesize functions,tblView,dict,dictPath; 46 | static id shd=nil; 47 | +(id)sharedInstance{ 48 | if (!shd){ 49 | shd=[[self alloc] initForContentSize:CGSizeMake(320,480)]; 50 | } 51 | return shd; 52 | } 53 | - (id) initForContentSize:(CGSize)size { 54 | 55 | if ((self = [super initForContentSize:size]) != nil) { 56 | NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init]; 57 | self.dictPath=@"/var/mobile/Library/Preferences/libnotify.plist"; 58 | self.dict=[NSMutableDictionary dictionaryWithContentsOfFile:self.dictPath]; 59 | 60 | 61 | if (!self.dict || [self.dict valueForKey:@"functions"]==nil){ 62 | NSMutableDictionary *dictnotifypost=[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:1],@"Enabled",@"notify_post",@"functionName",nil]; 63 | NSMutableDictionary *dictDarwin=[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:1],@"Enabled",@"CFNotificationCenter(Darwin)",@"functionName",nil]; 64 | NSMutableDictionary *dictNSNotif=[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:1],@"Enabled",@"NSNotificationCenter",@"functionName",nil]; 65 | NSMutableDictionary *dictCopyAppValue=[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:0],@"Enabled",@"CFPreferencesCopyAppValue",@"functionName",nil]; 66 | NSMutableDictionary *dictSqlite=[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:0],@"Enabled",@"Sqlite3 Queries",@"functionName",nil]; 67 | NSMutableDictionary *dictCPDist=[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:0],@"Enabled",@"CPDistributedMessagingCenter",@"functionName",nil]; 68 | 69 | NSMutableArray *functArr=[NSMutableArray arrayWithObjects:dictnotifypost,dictDarwin,dictCPDist,dictNSNotif,dictCopyAppValue,dictSqlite,nil]; 70 | self.dict=[NSMutableDictionary dictionary]; 71 | [self.dict setObject:functArr forKey:@"functions"]; 72 | [self.dict writeToFile:self.dictPath atomically:YES]; 73 | self.functions=[self.dict objectForKey:@"functions"]; 74 | } 75 | else{ 76 | self.functions=[self.dict objectForKey:@"functions"]; 77 | } 78 | 79 | 80 | 81 | self.tblView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 480-64) style:UITableViewStyleGrouped]; 82 | [self.tblView setDataSource:self]; 83 | [self.tblView setDelegate:self]; 84 | [self.tblView setEditing:YES]; 85 | [self.tblView setAllowsSelectionDuringEditing:YES]; 86 | if ([self respondsToSelector:@selector(setView:)]) 87 | [self setView:self.tblView]; 88 | 89 | [pool drain]; 90 | } 91 | return self; 92 | } 93 | 94 | 95 | 96 | - (int) numberOfSectionsInTableView:(UITableView *)tableView { 97 | return 1; 98 | } 99 | 100 | - (id) tableView:(UITableView *)tableView titleForHeaderInSection:(int)section { 101 | return nil; 102 | } 103 | 104 | - (int) tableView:(UITableView *)tableView numberOfRowsInSection:(int)section { 105 | 106 | return self.functions.count; 107 | 108 | } 109 | 110 | - (id) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 111 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FunctionCell"]; 112 | if (!cell) { 113 | cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 100, 100) reuseIdentifier:@"FunctionCell"] autorelease]; 114 | } 115 | NSAutoreleasePool *p=[[NSAutoreleasePool alloc] init]; 116 | 117 | NSString *function=[self.functions objectAtIndex:indexPath.row]; 118 | cell.text = [function valueForKey:@"functionName"]; 119 | cell.hidesAccessoryWhenEditing = NO; 120 | 121 | 122 | if ([[function valueForKey:@"Enabled"] boolValue]==1){ 123 | [cell setImage:[UIImage imageWithContentsOfFile: [[NSBundle bundleWithIdentifier:@"libnotify"] pathForResource:@"BlueCheck" ofType:@"png"] ] ]; 124 | 125 | } 126 | else{ 127 | [cell setImage:[UIImage imageWithContentsOfFile: [[NSBundle bundleWithIdentifier:@"libnotify"] pathForResource:@"WhiteSpace" ofType:@"png"] ] ]; 128 | 129 | } 130 | 131 | [p drain]; 132 | return cell; 133 | } 134 | 135 | - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 136 | UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 137 | 138 | [cell setSelectedTextColor:[UIColor whiteColor]]; 139 | 140 | if ([[[self.functions objectAtIndex:indexPath.row] valueForKey:@"Enabled"] boolValue]==0){ 141 | [[self.functions objectAtIndex:indexPath.row] setValue:[NSNumber numberWithBool:1] forKey:@"Enabled"]; 142 | [self.dict setObject:self.functions forKey:@"functions"]; 143 | [self.dict writeToFile:self.dictPath atomically:YES]; 144 | [cell setImage:[UIImage imageWithContentsOfFile: [[NSBundle bundleWithIdentifier:@"libnotify"] pathForResource:@"BlueCheck" ofType:@"png"] ] ]; 145 | } 146 | 147 | else{ 148 | [[self.functions objectAtIndex:indexPath.row] setValue:[NSNumber numberWithBool:0] forKey:@"Enabled"]; 149 | [self.dict setObject:self.functions forKey:@"functions"]; 150 | [self.dict writeToFile:self.dictPath atomically:YES]; 151 | [cell setImage:[UIImage imageWithContentsOfFile: [[NSBundle bundleWithIdentifier:@"libnotify"] pathForResource:@"WhiteSpace" ofType:@"png"] ] ]; 152 | } 153 | 154 | [tableView deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:YES]; 155 | [tableView reloadData]; 156 | notify_post("libnotify.prefsChanged"); 157 | } 158 | 159 | 160 | 161 | - (UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { 162 | return UITableViewCellEditingStyleNone; 163 | } 164 | 165 | - (BOOL) tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath { 166 | return NO; 167 | } 168 | 169 | 170 | - (void) dealloc { 171 | [self.tblView release]; 172 | [self.functions release]; 173 | [self.dictPath release]; 174 | [self.dict release]; 175 | [super dealloc]; 176 | } 177 | 178 | - (id) navigationTitle { 179 | return @"Functions"; 180 | } 181 | - (id) title { 182 | return @"Functions"; 183 | } 184 | 185 | - (id) view { 186 | return self.tblView; 187 | } 188 | 189 | 190 | @end 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | @implementation LibNotifyController 202 | - (id)specifiers { 203 | if(_specifiers == nil) { 204 | _specifiers = [[self loadSpecifiersFromPlistName:@"LibNotifyWatch" target:self] retain]; 205 | } 206 | return _specifiers; 207 | } 208 | @end 209 | 210 | 211 | #define WBSAddMethod(_class, _sel, _imp, _type) \ 212 | if (![[_class class] instancesRespondToSelector:@selector(_sel)]) \ 213 | class_addMethod([_class class], @selector(_sel), (IMP)_imp, _type) 214 | void $PSRootController$popController(PSRootController *self, SEL _cmd) { 215 | [self popViewControllerAnimated:YES]; 216 | } 217 | 218 | void $PSViewController$hideNavigationBarButtons(PSRootController *self, SEL _cmd) { 219 | } 220 | 221 | id $PSViewController$initForContentSize$(PSRootController *self, SEL _cmd, CGRect contentSize) { 222 | return [self init]; 223 | } 224 | 225 | static __attribute__((constructor)) void __dcsInit() { 226 | NSAutoreleasePool *p=[[NSAutoreleasePool alloc] init]; 227 | WBSAddMethod(PSRootController, popController, $PSRootController$popController, "v@:"); 228 | WBSAddMethod(PSViewController, hideNavigationBarButtons, $PSViewController$hideNavigationBarButtons, "v@:"); 229 | WBSAddMethod(PSViewController, initForContentSize:, $PSViewController$initForContentSize$, "@@:{ff}"); 230 | [p drain]; 231 | } 232 | -------------------------------------------------------------------------------- /preferenceBundle/Makefile: -------------------------------------------------------------------------------- 1 | GO_EASY_ON_ME=1 2 | include theos/makefiles/common.mk 3 | 4 | BUNDLE_NAME = LibNotifyWatch 5 | LibNotifyWatch_FILES = LibNotifyWatch.mm 6 | LibNotifyWatch_INSTALL_PATH = /Library/PreferenceBundles 7 | LibNotifyWatch_FRAMEWORKS = UIKit 8 | LibNotifyWatch_PRIVATE_FRAMEWORKS = Preferences 9 | LibNotifyWatch_LDFLAGS=-lsubstrate 10 | include $(THEOS_MAKE_PATH)/bundle.mk 11 | 12 | internal-stage:: 13 | $(ECHO_NOTHING)mkdir -p $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences$(ECHO_END) 14 | $(ECHO_NOTHING)cp entry.plist $(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences/LibNotifyWatch.plist$(ECHO_END) 15 | -------------------------------------------------------------------------------- /preferenceBundle/Resources/BlueCheck.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/preferenceBundle/Resources/BlueCheck.png -------------------------------------------------------------------------------- /preferenceBundle/Resources/BlueCheck@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/preferenceBundle/Resources/BlueCheck@2x.png -------------------------------------------------------------------------------- /preferenceBundle/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | LibNotifyWatch 9 | CFBundleIdentifier 10 | libnotify 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.0 21 | DTPlatformName 22 | iphoneos 23 | MinimumOSVersion 24 | 3.0 25 | NSPrincipalClass 26 | LibNotifyListController 27 | 28 | 29 | -------------------------------------------------------------------------------- /preferenceBundle/Resources/LibNotify.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | cell 9 | PSGroupCell 10 | label 11 | ScrollingBoardPrefs First Page 12 | 13 | 14 | cell 15 | PSSwitchCell 16 | default 17 | 18 | defaults 19 | net.limneos.scrollingboardprefs 20 | key 21 | AwesomeSwitch1 22 | label 23 | Awesome Switch 1 24 | 25 | 26 | title 27 | ScrollingBoardPrefs 28 | 29 | 30 | -------------------------------------------------------------------------------- /preferenceBundle/Resources/LibNotifyWatch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/preferenceBundle/Resources/LibNotifyWatch -------------------------------------------------------------------------------- /preferenceBundle/Resources/LibNotifyWatch.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | items 6 | 7 | 8 | PostNotification 9 | libnotify.prefsChanged 10 | cell 11 | PSSwitchCell 12 | default 13 | 14 | defaults 15 | libnotify 16 | key 17 | enabled 18 | label 19 | Enable Logging 20 | 21 | 22 | cell 23 | PSGroupCell 24 | label 25 | Functions To Watch 26 | 27 | 28 | cell 29 | PSLinkListCell 30 | defaults 31 | libnotify 32 | detail 33 | LibNotifyViewController 34 | key 35 | choosefunctions 36 | label 37 | Select Functions 38 | 39 | 40 | cell 41 | PSGroupCell 42 | label 43 | Filter Notifications 44 | 45 | 46 | PostNotification 47 | libnotify.prefsChanged 48 | cell 49 | PSEditTextCell 50 | defaults 51 | libnotify 52 | key 53 | filter 54 | label 55 | Containing string: 56 | 57 | 58 | cell 59 | PSGroupCell 60 | footerText 61 | Logs are written to /var/log/syslog. Make sure syslogd is active 62 | 63 | 64 | cell 65 | PSGroupCell 66 | footerText 67 | Suggested usage: tail -f /var/log/syslog | grep -i libnotifywatch 68 | 69 | 70 | alignment 71 | 0.0 72 | cell 73 | PSGroupCell 74 | label 75 | Warning: Extensive logging can cause lag to your device. Make sure you only use it when you need to. 76 | 77 | 78 | title 79 | LibNotifyWatch 80 | 81 | 82 | -------------------------------------------------------------------------------- /preferenceBundle/Resources/LibNotifyWatch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/preferenceBundle/Resources/LibNotifyWatch.png -------------------------------------------------------------------------------- /preferenceBundle/Resources/LibNotifyWatch@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/preferenceBundle/Resources/LibNotifyWatch@2x.png -------------------------------------------------------------------------------- /preferenceBundle/Resources/WhiteSpace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/preferenceBundle/Resources/WhiteSpace.png -------------------------------------------------------------------------------- /preferenceBundle/Resources/WhiteSpace@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/limneos/LibNotifyWatch/d8de0d63fee339ddb6719e8f34a7d43b87f3b874/preferenceBundle/Resources/WhiteSpace@2x.png -------------------------------------------------------------------------------- /preferenceBundle/entry.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | entry 6 | 7 | bundle 8 | LibNotifyWatch 9 | cell 10 | PSLinkCell 11 | detail 12 | LibNotifyListController 13 | icon 14 | LibNotifyWatch.png 15 | isController 16 | 1 17 | label 18 | LibNotifyWatch 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | LibNotifyWatch 2 | ============== 3 | Log system-posted notifications 4 | ------------------------------- 5 | 6 | by Elias Limneos 7 | ---------------- 8 | web: limneos.net 9 | 10 | email: iphone (at) limneos (dot) net 11 | 12 | twitter: @limneos 13 | 14 | Intro 15 | ----- 16 | 17 | LibNotifyWatch is useful mostly to developers and in particular, those 18 | who are bored to hook and log system notifications. 19 | It hooks several notification-posting functions and writes them to 20 | /var/log/syslog using NSLog. (syslogd must be running). 21 | It provides options to select which notification-posting functions to 22 | watch/log , as well as filtering for notification names. 23 | 24 | 25 | Settings 26 | -------- 27 | 28 | LibNotifyWatch offers a preferenceBundle in which you can define which 29 | functions to watch and write to /var/log/syslog. 30 | You can turn global logging on/off, define which functions to watch in 31 | particular, or define a string filter so you can only 32 | log notifications matching your filter. 33 | 34 | Open Source 35 | ----------- 36 | 37 | LibNotifyWatch is open-source, any help / modification / addition is 38 | appreaciated. 39 | 40 | 41 | Compile 42 | ------- 43 | 44 | LibNotifyWatch is compiled using Theos. For more information about 45 | Theos/Logos, visit http://bit.ly/af0Evu and http://hwtt.net/ths 46 | 47 | 48 | Thanks 49 | ------ 50 | 51 | Thanks to: 52 | 53 | Optimo for being my mentor 54 | 55 | DHowett for Theos/Logos and all the background work he's done for the community 56 | 57 | Saurik for cycript and everything else 58 | 59 | Many other developers from IRC from which I've learned a lot, including 60 | rpetrich, BigBoss, DB42, kennytm, chpwn, mringwal, TheZimm, Yllier 61 | 62 | 63 | --------------------------------------------------------------------------------