DrunkenBass
# uname -a
Darwin iPhone 9.0.0d1 Darwin Kernel Version 9.0.0d1: Wed Sep 19 00:08:43 PDT 2007; root:xnu-933.0.0.203.obj~21/RELEASE_ARM_S5L8900XRB iPhone1,1 Darwin
# pwd
/var/root/Library/Installer/Temp
# md5 caissa_0.8.zip
a84208e384a7695c2bd5f2152c52d52f caissa_0.8.zip
2007-12-17 23:40:34.527 Installer[20773:d03] ATPackageManager: Perfoming operation "Install" on package "Caissa"...
2007-12-17 23:40:34.533 Installer[20773:d03] ATPackageManager: Status: Downloading package...
2007-12-17 23:40:34.567 Installer[20773:d03] ATPackageManager: Queue was put on hold.
2007-12-17 23:40:42.168 Installer[20773:d03] ATDownloader: Downloaded package to: /var/root/Library/Installer/Temp/caissa_0.8.zip
2007-12-17 23:40:42.183 Installer[20773:d03] ATPackageManager: Status: Checking package...
2007-12-17 23:40:42.243 Installer[20773:d03] ATDownloader: Invalid package hash "a84208e384a7695c2bd5f2152c52d52f"!
<key>description</key>
<string>Native chess game</string>
<key>hash</key>
<string>a84208e384a7695c2bd5f2152c52d52f</string>
// With SMS text & address contributions from Saurik
#import <UIKit/UIKit.h>
#import <UIKit/UIApplication.h>
#include <notify.h>
#include <stdio.h>
#include <stdarg.h>
typedef struct __CTSMSMessage CTSMSMessage;
NSString *CTSMSMessageCopyAddress(void *, CTSMSMessage *);
NSString *CTSMSMessageCopyText(void *, CTSMSMessage *);
void dolog(id formatstring,...)
{
va_list arglist;
if (formatstring)
{
va_start(arglist, formatstring);
id outstring = [[NSString alloc] initWithFormat:formatstring arguments:arglist];
printf("%s\n", [outstring UTF8String]);
va_end(arglist);
}
}
static void callback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
printf("NOTIFICATION: %s\n", [name UTF8String]);
if (!userInfo) return;
NSDictionary *info = userInfo;
int dcount = CFDictionaryGetCount(userInfo);
id keys = [userInfo allKeys];
int i;
for (i = 0; i < dcount; i++)
{
id key = [keys objectAtIndex:i];
dolog(@" %@: %@", key, [info objectForKey:key]);
}
if ([[(NSDictionary *)userInfo allKeys]
containsObject:@"kCTSMSMessage"]) // SMS Message
{
CTSMSMessage *message = (CTSMSMessage *)
[(NSDictionary *)userInfo objectForKey:@"kCTSMSMessage"];
NSString *address = CTSMSMessageCopyAddress(NULL, message);
NSString *text = CTSMSMessageCopyText(NULL, message);
NSArray *lines = [text componentsSeparatedByString:@"\n"];
printf(" %s %d\n", [address cString], [lines count]);
printf(" %s\n", [text cString]);
fflush(stdout);
}
[pool release];
return 0;
}
static void signalHandler(int sigraised) {
printf("\nInterrupted.\n"); exit(0); }
int main(int argc, char **argv)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// Initialize listener by adding CT Center observer
extern NSString* const kCTSMSMessageReceivedNotification;
id ct = CTTelephonyCenterGetDefault();
CTTelephonyCenterAddObserver(
ct,
NULL,
callback,
NULL,
NULL,
CFNotificationSuspensionBehaviorHold);
// Handle Interrupts
sig_t oldHandler = signal(SIGINT, signalHandler);
if (oldHandler == SIG_ERR) {
printf("Could not establish new signal handler");
exit(1); }
// Run loop lets me catch notifications
printf("Starting run loop and watching for notification.\n");
CFRunLoopRun();
// Shouldn't ever get here. Bzzzt
printf("Unexpectedly back from CFRunLoopRun()!\n");
}