Skip to content

Commit

Permalink
Public Release 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rpetrich committed Apr 21, 2011
0 parents commit b334e37
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
.theos
*.deb
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "framework"]
path = framework
url = git://github.com/rpetrich/theos.git
9 changes: 9 additions & 0 deletions Makefile
@@ -0,0 +1,9 @@
TOOL_NAME = untrackerd
untrackerd_FILES = untrackerd.c
untrackerd_FRAMEWORKS = CoreFoundation
untrackerd_LDFLAGS = -lsqlite3 -Wl,-stack_size,1000

ADDITIONAL_CFLAGS = -std=c99

include framework/makefiles/common.mk
include framework/makefiles/tool.mk
1 change: 1 addition & 0 deletions framework
Submodule framework added at 51ede7
9 changes: 9 additions & 0 deletions layout/DEBIAN/control
@@ -0,0 +1,9 @@
Package: com.rpetrich.untrackerd
Priority: optional
Section: System
Architecture: iphoneos-arm
Version: 0.1
Description: Continuously clean up locationd's history data
Name: untrackerd
Depends: firmware (>= 4.0)
Author: Ryan Petrich <rpetrich+untrackerd@gmail.com>
7 changes: 7 additions & 0 deletions layout/DEBIAN/postinst
@@ -0,0 +1,7 @@
#!/bin/sh
chown root:wheel /usr/bin/untrackerd
chmod 755 /usr/bin/untrackerd
chown root:wheel /Library/LaunchDaemons/com.rpetrich.untrackerd.plist
chmod 644 /Library/LaunchDaemons/com.rpetrich.untrackerd.plist
/bin/launchctl load -w /Library/LaunchDaemons/com.rpetrich.untrackerd.plist
exit 0
3 changes: 3 additions & 0 deletions layout/DEBIAN/prerm
@@ -0,0 +1,3 @@
#!/bin/sh
/bin/launchctl unload /Library/LaunchDaemons/com.rpetrich.untrackerd.plist
exit 0
19 changes: 19 additions & 0 deletions layout/Library/LaunchDaemons/com.rpetrich.untrackerd.plist
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

<dict>
<key>Label</key>
<string>com.rpetrich.untrackerd</string>

<key>Program</key>
<string>/usr/bin/untrackerd</string>

<key>StandardErrorPath</key>
<string>/dev/null</string>

<key>OnDemand</key>
<false/>
</dict>

</plist>
62 changes: 62 additions & 0 deletions untrackerd.c
@@ -0,0 +1,62 @@
#include <stdio.h>
#include <CoreFoundation/CoreFoundation.h>
#include <sqlite3.h>

// untrackerd
// Ryan Petrich
// Continuously clean up locationd's history data

static inline bool clear_data()
{
sqlite3 *database = NULL;
// Open Database
int result = sqlite3_open("/var/root/Library/Caches/locationd/consolidated.db", &database);
if (result == SQLITE_OK) {
sqlite3_stmt *statement = NULL;
CFAbsoluteTime time = CFAbsoluteTimeGetCurrent() - (60.0 * 30.0);
// Clear Cell data
result = sqlite3_prepare_v2(database, "DELETE FROM CellLocation WHERE Timestamp < ?;", -1, &statement, NULL);
if (result == SQLITE_OK) {
result = sqlite3_bind_double(statement, 1, time);
if (result == SQLITE_OK) {
do {
result = sqlite3_step(statement);
} while (result == SQLITE_ROW);
}
sqlite3_finalize(statement);
}
// Clear WiFi Data
if (result == SQLITE_DONE) {
result = sqlite3_prepare_v2(database, "DELETE FROM WifiLocation WHERE Timestamp < ?;", -1, &statement, NULL);
if (result == SQLITE_OK) {
result = sqlite3_bind_double(statement, 1, time);
if (result == SQLITE_OK) {
do {
result = sqlite3_step(statement);
} while (result == SQLITE_ROW);
}
sqlite3_finalize(statement);
}
}
// Close Database
sqlite3_close(database);
}
return (result == SQLITE_OK) || (result == SQLITE_DONE);
}

static void timer_callback(CFRunLoopTimerRef timer, void *info)
{
clear_data();
}

int main(int argc, const char *argv[])
{
// Loop ad infinitum
CFRunLoopTimerRef timer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent(), (5.0 * 60.0), 0, 0, &timer_callback, NULL);
CFRunLoopRef loop = CFRunLoopGetCurrent();
CFRunLoopAddTimer(loop, timer, kCFRunLoopCommonModes);
CFRunLoopRun();
CFRunLoopRemoveTimer(loop, timer, kCFRunLoopCommonModes);
CFRelease(timer);
return 0;
}

0 comments on commit b334e37

Please sign in to comment.