+MSHook(void, SBIconLabel$setInDock$, SBIconLabel *self, SEL sel, BOOL docked) {
+ id &_label(MSHookIvar<id>(self, "_label"));
+ if (![Info_ wb$boolForKey:@"UndockedIconLabels"])
+ docked = true;
+ if (_label != nil && [_label respondsToSelector:@selector(setInDock:)])
+ [_label setInDock:docked];
+ return _SBIconLabel$setInDock$(self, sel, docked);
+}
+
+MSHook(NSString *, NSBundle$localizedStringForKey$value$table$, NSBundle *self, SEL sel, NSString *key, NSString *value, NSString *table) {
+ NSString *identifier = [self bundleIdentifier];
+ NSLocale *locale = [NSLocale currentLocale];
+ NSString *language = [locale objectForKey:NSLocaleLanguageCode];
+ if (Debug_)
+ NSLog(@"WB:Debug:[NSBundle(%@) localizedStringForKey:\"%@\" value:\"%@\" table:\"%@\"] (%@)", identifier, key, value, table, language);
+ NSString *file = table == nil ? @"Localizable" : table;
+ NSString *name = [NSString stringWithFormat:@"%@:%@", identifier, file];
+ NSDictionary *strings;
+ if ((strings = [Strings_ objectForKey:name]) != nil) {
+ if (static_cast<id>(strings) != [NSNull null]) strings:
+ if (NSString *value = [strings objectForKey:key])
+ return value;
+ } else if (NSString *path = $pathForFile$inBundle$([NSString stringWithFormat:@"%@.lproj/%@.strings",
+ language, file
+ ], self, false)) {
+ if ((strings = [[NSDictionary alloc] initWithContentsOfFile:path]) != nil) {
+ [Strings_ setObject:[strings autorelease] forKey:name];
+ goto strings;
+ } else goto null;
+ } else null:
+ [Strings_ setObject:[NSNull null] forKey:name];
+ return _NSBundle$localizedStringForKey$value$table$(self, sel, key, value, table);
+}
+
+@class WebCoreFrameBridge;
+MSHook(CGSize, WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$, WebCoreFrameBridge *self, SEL sel, id node, float width) {
+ if (node == nil)
+ return CGSizeZero;
+ void **core(reinterpret_cast<void **>([node _node]));
+ if (core == NULL || core[6] == NULL)
+ return CGSizeZero;
+ return _WebCoreFrameBridge$renderedSizeOfNode$constrainedToWidth$(self, sel, node, width);
+}
+
+MSHook(void, SBIconLabel$drawRect$, SBIconLabel *self, SEL sel, CGRect rect) {
+ CGRect bounds = [self bounds];
+
+ static Ivar drawMoreLegibly = object_getInstanceVariable(self, "_drawMoreLegibly", NULL);
+
+ BOOL docked;
+ Ivar ivar = object_getInstanceVariable(self, "_inDock", reinterpret_cast<void **>(&docked));
+ docked = (docked & (ivar_getOffset(ivar) == ivar_getOffset(drawMoreLegibly) ? 0x2 : 0x1)) != 0;
+
+ NSString *label(MSHookIvar<NSString *>(self, "_label"));
+
+ NSString *style = [NSString stringWithFormat:@""
+ "font-family: Helvetica; "
+ "font-weight: bold; "
+ "font-size: 11px; "
+ "color: %@; "
+ "", docked ? @"white" : @"#b3b3b3"];
+
+ if (docked)
+ style = [style stringByAppendingString:@"text-shadow: rgba(0, 0, 0, 0.5) 0px -1px 0px; "];
+
+ bool ellipsis(false);
+ float max = 75, width;
+ width:
+ width = [(ellipsis ? [label stringByAppendingString:@"..."] : label) sizeWithStyle:style forWidth:320].width;
+
+ if (width > max) {
+ size_t length([label length]);
+ float spacing((width - max) / (length - 1));
+
+ if (spacing > 1.25) {
+ ellipsis = true;
+ label = [label substringToIndex:(length - 1)];
+ goto width;
+ }
+
+ style = [style stringByAppendingString:[NSString stringWithFormat:@"letter-spacing: -%f; ", spacing]];
+ }
+
+ if (ellipsis)
+ label = [label stringByAppendingString:@"..."];
+
+ if (NSString *custom = [Info_ objectForKey:(docked ? @"DockedIconLabelStyle" : @"UndockedIconLabelStyle")])
+ style = [style stringByAppendingString:custom];
+
+ CGSize size = [label sizeWithStyle:style forWidth:bounds.size.width];
+ [label drawAtPoint:CGPointMake((bounds.size.width - size.width) / 2, 0) withStyle:style];
+}
+
+MSHook(void, CKMessageCell$addBalloonView$, id self, SEL sel, CKBalloonView *balloon) {
+ _CKMessageCell$addBalloonView$(self, sel, balloon);
+ [balloon setBackgroundColor:[UIColor clearColor]];
+}
+
+MSHook(id, CKMessageCell$initWithStyle$reuseIdentifier$, id self, SEL sel, int style, NSString *reuse) {
+ if ((self = _CKMessageCell$initWithStyle$reuseIdentifier$(self, sel, style, reuse)) != nil) {
+ [[self contentView] setBackgroundColor:[UIColor clearColor]];
+ } return self;
+}
+
+MSHook(id, CKTimestampView$initWithStyle$reuseIdentifier$, id self, SEL sel, int style, NSString *reuse) {
+ if ((self = _CKTimestampView$initWithStyle$reuseIdentifier$(self, sel, style, reuse)) != nil) {
+ UILabel *&_label(MSHookIvar<UILabel *>(self, "_label"));
+ [_label setBackgroundColor:[UIColor clearColor]];
+ } return self;
+}
+
+MSHook(void, CKTranscriptTableView$setSeparatorStyle$, id self, SEL sel, int style) {
+ _CKTranscriptTableView$setSeparatorStyle$(self, sel, UITableViewCellSeparatorStyleNone);
+}
+
+MSHook(id, CKTranscriptTableView$initWithFrame$style$, id self, SEL sel, CGRect frame, int style) {
+ _trace();
+ if ((self = _CKTranscriptTableView$initWithFrame$style$(self, sel, frame, style)) != nil) {
+ [self setSeparatorStyle:UITableViewCellSeparatorStyleNone];
+ } return self;
+}
+
+MSHook(void, TranscriptController$loadView, mSMSMessageTranscriptController *self, SEL sel) {
+ _TranscriptController$loadView(self, sel);
+
+ if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"SMSBackground.png", @"SMSBackground.jpg", nil]))
+ if (UIImage *image = [[UIImage alloc] initWithContentsOfFile:path]) {
+ [image autorelease];
+
+ UIView *&_transcriptTable(MSHookIvar<UIView *>(self, "_transcriptTable"));
+ UIView *&_transcriptLayer(MSHookIvar<UIView *>(self, "_transcriptLayer"));
+ UIView *table;
+ if (&_transcriptTable != NULL)
+ table = _transcriptTable;
+ else if (&_transcriptLayer != NULL)
+ table = _transcriptLayer;
+ else
+ table = nil;
+
+ UIView *placard(table != nil ? [table superview] : MSHookIvar<UIView *>(self, "_backPlacard"));
+ UIImageView *background([[[UIImageView alloc] initWithImage:image] autorelease]);
+
+ if (table == nil)
+ [placard insertSubview:background atIndex:0];
+ else {
+ [table setBackgroundColor:[UIColor clearColor]];
+ [placard insertSubview:background belowSubview:table];
+ }
+ }
+}
+
+MSHook(UIImage *, _UIImageWithName, NSString *name) {
+ int id(_UISharedImageNameGetIdentifier(name));
+ if (Debug_)
+ NSLog(@"WB:Debug: _UIImageWithName(\"%@\": %d)", name, id);
+
+ if (id == -1)
+ return _UIImageAtPath(name, _UIKitBundle());
+ else {
+ NSNumber *key([NSNumber numberWithInt:id]);
+ UIImage *image = [UIImages_ objectForKey:key];
+ if (image != nil)
+ return reinterpret_cast<id>(image) == [NSNull null] ? _UISharedImageWithIdentifier(id) : image;
+ if (NSString *path = $pathForFile$inBundle$(name, _UIKitBundle(), true)) {
+ image = [[UIImage alloc] initWithContentsOfFile:path cache:true];
+ if (image != nil)
+ [image autorelease];
+ }
+ [UIImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
+ return image == nil ? _UISharedImageWithIdentifier(id) : image;
+ }
+}
+
+MSHook(UIImage *, _UIImageWithNameInDomain, NSString *name, NSString *domain) {
+ NSString *key([NSString stringWithFormat:@"D:%zu%@%@", [domain length], domain, name]);
+ UIImage *image([PathImages_ objectForKey:key]);
+ if (image != nil)
+ return reinterpret_cast<id>(image) == [NSNull null] ? __UIImageWithNameInDomain(name, domain) : image;
+ if (Debug_)
+ NSLog(@"WB:Debug: UIImageWithNameInDomain(\"%@\", \"%@\")", name, domain);
+ if (NSString *path = $getTheme$([NSArray arrayWithObject:[NSString stringWithFormat:@"Domains/%@/%@", domain, name]])) {
+ image = [[UIImage alloc] initWithContentsOfFile:path];
+ if (image != nil)
+ [image autorelease];
+ }
+ [PathImages_ setObject:(image == nil ? [NSNull null] : reinterpret_cast<id>(image)) forKey:key];
+ return image == nil ? __UIImageWithNameInDomain(name, domain) : image;
+}
+
+MSHook(GSFontRef, GSFontCreateWithName, const char *name, GSFontSymbolicTraits traits, float size) {
+ if (Debug_)
+ NSLog(@"WB:Debug: GSFontCreateWithName(\"%s\", %f)", name, size);
+ if (NSString *font = [Info_ objectForKey:[NSString stringWithFormat:@"FontName-%s", name]])
+ name = [font UTF8String];
+ return _GSFontCreateWithName(name, traits, size);
+}
+
+#define AudioToolbox "/System/Library/Frameworks/AudioToolbox.framework/AudioToolbox"
+#define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit"
+
+bool (*_Z24GetFileNameForThisActionmPcRb)(unsigned long a0, char *a1, bool &a2);
+
+MSHook(bool, _Z24GetFileNameForThisActionmPcRb, unsigned long a0, char *a1, bool &a2) {
+ if (Debug_)
+ NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %p, %u)", a0, a1, a2);
+ bool value = __Z24GetFileNameForThisActionmPcRb(a0, a1, a2);
+ if (Debug_)
+ NSLog(@"WB:Debug:GetFileNameForThisAction(%u, %s, %u) = %u", a0, value ? a1 : NULL, a2, value);
+
+ if (value) {
+ NSString *path = [NSString stringWithUTF8String:a1];
+ if ([path hasPrefix:@"/System/Library/Audio/UISounds/"]) {
+ NSString *file = [path substringFromIndex:31];
+ for (NSString *theme in themes_) {
+ NSString *path([NSString stringWithFormat:@"%@/UISounds/%@", theme, file]);
+ if ([Manager_ fileExistsAtPath:path]) {
+ strcpy(a1, [path UTF8String]);
+ continue;
+ }
+ }
+ }
+ }
+ return value;
+}
+
+static void ChangeWallpaper(
+ CFNotificationCenterRef center,
+ void *observer,
+ CFStringRef name,
+ const void *object,
+ CFDictionaryRef info
+) {
+ if (Debug_)
+ NSLog(@"WB:Debug:ChangeWallpaper!");
+
+ UIImage *image;
+ if (WallpaperFile_ != nil) {
+ image = [[UIImage alloc] initWithContentsOfFile:WallpaperFile_];
+ if (image != nil)
+ image = [image autorelease];
+ } else image = nil;
+
+ if (WallpaperImage_ != nil)
+ [WallpaperImage_ setImage:image];
+ if (WallpaperPage_ != nil)
+ [WallpaperPage_ loadRequest:[NSURLRequest requestWithURL:WallpaperURL_]];
+
+}
+
+#define WBRename(name, sel, imp) \
+ _ ## name ## $ ## imp = MSHookMessage($ ## name, @selector(sel), &$ ## name ## $ ## imp)
+
+template <typename Type_>
+static void nlset(Type_ &function, struct nlist *nl, size_t index) {
+ struct nlist &name(nl[index]);
+ uintptr_t value(name.n_value);
+ if ((name.n_desc & N_ARM_THUMB_DEF) != 0)
+ value |= 0x00000001;
+ function = reinterpret_cast<Type_>(value);
+}
+
+template <typename Type_>
+static void dlset(Type_ &function, const char *name) {
+ function = reinterpret_cast<Type_>(dlsym(RTLD_DEFAULT, name));
+}
+