⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prerm.m

📁 iPhone 5 icon dock - customization
💻 M
字号:
#import <Foundation/Foundation.h>

#include <sys/types.h>
#include <pwd.h>
#include <unistd.h>

int main(int argc, const char *argv[]) {
    if (argc < 2 || strcmp(argv[1], "remove") != 0)
        return 0;

    struct passwd *passwd = getpwnam("mobile");
    if (passwd == NULL) {
        perror("getpwnam");
        return 0;
    }

    if (setregid(passwd->pw_gid, passwd->pw_gid) == -1) {
        perror("setregid");
        return 1;
    }

    if (setreuid(passwd->pw_uid, passwd->pw_uid) == -1) {
        perror("setreuid");
        return 1;
    }

    NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]);

    NSString *path([NSString stringWithFormat:@"%@/Library/Preferences/com.apple.springboard.plist", NSHomeDirectory()]);

    NSMutableDictionary *settings([[NSMutableDictionary alloc] initWithContentsOfFile:path]);
    if (settings == nil)
        return 0;

    NSMutableDictionary *iconState([settings objectForKey:@"iconState"]);
    if (iconState == nil)
        return 0;

    NSMutableDictionary *buttonBar([iconState objectForKey:@"buttonBar"]);
    if (buttonBar == nil)
        return 0;

    NSMutableArray *buttonBarIconMatrix([buttonBar objectForKey:@"iconMatrix"]);
    if (buttonBarIconMatrix == nil || [buttonBarIconMatrix count] == 0)
        return 0;

    NSMutableArray *buttonBarRow([buttonBarIconMatrix objectAtIndex:0]);
    if (buttonBarRow == nil || [buttonBarRow count] < 5)
        return 0;

    NSMutableDictionary *fifth([buttonBarRow objectAtIndex:4]);

    if (![fifth isEqual:[NSNumber numberWithInt:0]]) {
        NSMutableArray *iconLists([iconState objectForKey:@"iconLists"]);
        if (iconLists == nil)
            iconLists = [NSMutableArray arrayWithCapacity:1];
        else for (NSUInteger i(0), e([iconLists count]); i != e; ++i) {
            NSMutableDictionary *iconList([iconLists objectAtIndex:i]);
            NSMutableArray *iconMatrix([iconList objectForKey:@"iconMatrix"]);
            if (iconMatrix == nil)
                continue;

            for (NSUInteger i(0), e([iconMatrix count]); i != e; ++i) {
                NSMutableArray *row([iconMatrix objectAtIndex:i]);
                NSUInteger spot([row indexOfObject:[NSNumber numberWithInteger:0]]);
                if (spot != NSNotFound) {
                    [row replaceObjectAtIndex:i withObject:fifth];
                    goto save;
                }
            }
        }

        [iconLists addObject:[NSDictionary dictionaryWithObjectsAndKeys:
            [NSArray arrayWithObjects:[NSArray arrayWithObject:fifth], nil], @"iconMatrix",
        nil]];
    }

  save:
    [buttonBarRow removeLastObject];
    bool saved([settings writeToFile:path atomically:YES]);

    [pool release];

    return saved ? 0 : 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -