]> git.saurik.com Git - cydia.git/commitdiff
Added settings and sources to manage and fixed a few small nits.
authorJay Freeman (saurik) <saurik@saurk.com>
Sat, 2 Aug 2008 00:07:34 +0000 (00:07 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 30 Sep 2010 07:08:12 +0000 (07:08 +0000)
64 files changed:
Cydia.app/Administration.png [deleted file]
Cydia.app/Archiving.png [deleted file]
Cydia.app/Data Storage.png [deleted file]
Cydia.app/Development.png [deleted file]
Cydia.app/Games.png [deleted file]
Cydia.app/Java.png [deleted file]
Cydia.app/Localization.png [deleted file]
Cydia.app/Multimedia.png [deleted file]
Cydia.app/Networking.png [deleted file]
Cydia.app/Packaging.png [deleted file]
Cydia.app/Repositories.png [deleted file]
Cydia.app/Scripting.png [deleted file]
Cydia.app/Sections/Administration.png [new file with mode: 0644]
Cydia.app/Sections/Archiving.png [new file with mode: 0644]
Cydia.app/Sections/Data Storage.png [new file with mode: 0644]
Cydia.app/Sections/Development.png [new file with mode: 0644]
Cydia.app/Sections/Games.png [new file with mode: 0644]
Cydia.app/Sections/Java.png [new file with mode: 0644]
Cydia.app/Sections/Localization.png [new file with mode: 0644]
Cydia.app/Sections/Multimedia.png [new file with mode: 0644]
Cydia.app/Sections/Networking.png [new file with mode: 0644]
Cydia.app/Sections/Packaging.png [new file with mode: 0644]
Cydia.app/Sections/Planet-iPhones Mods.png [new file with mode: 0644]
Cydia.app/Sections/Productivity.png [new file with mode: 0644]
Cydia.app/Sections/Repositories.png [new file with mode: 0644]
Cydia.app/Sections/Scripting.png [new file with mode: 0644]
Cydia.app/Sections/Security.png [new file with mode: 0644]
Cydia.app/Sections/System.png [new file with mode: 0644]
Cydia.app/Sections/Terminal Support.png [new file with mode: 0644]
Cydia.app/Sections/Text Editors.png [new file with mode: 0644]
Cydia.app/Sections/Themes.png [new file with mode: 0644]
Cydia.app/Sections/Toys.png [new file with mode: 0644]
Cydia.app/Sections/Tweaks.png [new file with mode: 0644]
Cydia.app/Sections/Utilities.png [new file with mode: 0644]
Cydia.app/Sections/X Window.png [new file with mode: 0644]
Cydia.app/Security.png [deleted file]
Cydia.app/Sources/apt.bigboss.us.com.png [new file with mode: 0644]
Cydia.app/Sources/apt.saurik.com.png [new file with mode: 0644]
Cydia.app/Sources/iphone.hackndev.org.png [new file with mode: 0644]
Cydia.app/Sources/iphonehe. [new file with mode: 0644]
Cydia.app/Sources/modmyifone.com.png [new file with mode: 0644]
Cydia.app/Sources/repo.smxy.org.png [new file with mode: 0644]
Cydia.app/Sources/urbanfanatics.com.png [new file with mode: 0644]
Cydia.app/Sources/www.zodttd.com.png [new file with mode: 0644]
Cydia.app/System.png [deleted file]
Cydia.app/Terminal Support.png [deleted file]
Cydia.app/Text Editors.png [deleted file]
Cydia.app/Themes.png [deleted file]
Cydia.app/Toys.png [deleted file]
Cydia.app/Tweaks.png [deleted file]
Cydia.app/Utilities.png [deleted file]
Cydia.app/X Window.png [deleted file]
Cydia.app/error.html [new file with mode: 0644]
Cydia.app/home.html [deleted file]
Cydia.app/manage.html [new file with mode: 0644]
Cydia.app/packages.png [new file with mode: 0644]
Cydia.app/sections.txt [new file with mode: 0644]
Cydia.app/sources.png [new file with mode: 0644]
Cydia.app/storage.png [new file with mode: 0644]
Cydia.mm
UICaboodle/RVBook.mm
UICaboodle/RVPage.h
UICaboodle/RVPage.mm
makefile

diff --git a/Cydia.app/Administration.png b/Cydia.app/Administration.png
deleted file mode 100644 (file)
index 8b4b44f..0000000
Binary files a/Cydia.app/Administration.png and /dev/null differ
diff --git a/Cydia.app/Archiving.png b/Cydia.app/Archiving.png
deleted file mode 100644 (file)
index 68b486a..0000000
Binary files a/Cydia.app/Archiving.png and /dev/null differ
diff --git a/Cydia.app/Data Storage.png b/Cydia.app/Data Storage.png
deleted file mode 100644 (file)
index e8a8449..0000000
Binary files a/Cydia.app/Data Storage.png and /dev/null differ
diff --git a/Cydia.app/Development.png b/Cydia.app/Development.png
deleted file mode 100644 (file)
index 25afa9f..0000000
Binary files a/Cydia.app/Development.png and /dev/null differ
diff --git a/Cydia.app/Games.png b/Cydia.app/Games.png
deleted file mode 100644 (file)
index 6e0efaf..0000000
Binary files a/Cydia.app/Games.png and /dev/null differ
diff --git a/Cydia.app/Java.png b/Cydia.app/Java.png
deleted file mode 100644 (file)
index 4b543db..0000000
Binary files a/Cydia.app/Java.png and /dev/null differ
diff --git a/Cydia.app/Localization.png b/Cydia.app/Localization.png
deleted file mode 100644 (file)
index 2450175..0000000
Binary files a/Cydia.app/Localization.png and /dev/null differ
diff --git a/Cydia.app/Multimedia.png b/Cydia.app/Multimedia.png
deleted file mode 100644 (file)
index 07f20b6..0000000
Binary files a/Cydia.app/Multimedia.png and /dev/null differ
diff --git a/Cydia.app/Networking.png b/Cydia.app/Networking.png
deleted file mode 100644 (file)
index ee1f0a1..0000000
Binary files a/Cydia.app/Networking.png and /dev/null differ
diff --git a/Cydia.app/Packaging.png b/Cydia.app/Packaging.png
deleted file mode 100644 (file)
index c1b72a5..0000000
Binary files a/Cydia.app/Packaging.png and /dev/null differ
diff --git a/Cydia.app/Repositories.png b/Cydia.app/Repositories.png
deleted file mode 100644 (file)
index 29c9db0..0000000
Binary files a/Cydia.app/Repositories.png and /dev/null differ
diff --git a/Cydia.app/Scripting.png b/Cydia.app/Scripting.png
deleted file mode 100644 (file)
index d020f71..0000000
Binary files a/Cydia.app/Scripting.png and /dev/null differ
diff --git a/Cydia.app/Sections/Administration.png b/Cydia.app/Sections/Administration.png
new file mode 100644 (file)
index 0000000..8b4b44f
Binary files /dev/null and b/Cydia.app/Sections/Administration.png differ
diff --git a/Cydia.app/Sections/Archiving.png b/Cydia.app/Sections/Archiving.png
new file mode 100644 (file)
index 0000000..68b486a
Binary files /dev/null and b/Cydia.app/Sections/Archiving.png differ
diff --git a/Cydia.app/Sections/Data Storage.png b/Cydia.app/Sections/Data Storage.png
new file mode 100644 (file)
index 0000000..e8a8449
Binary files /dev/null and b/Cydia.app/Sections/Data Storage.png differ
diff --git a/Cydia.app/Sections/Development.png b/Cydia.app/Sections/Development.png
new file mode 100644 (file)
index 0000000..25afa9f
Binary files /dev/null and b/Cydia.app/Sections/Development.png differ
diff --git a/Cydia.app/Sections/Games.png b/Cydia.app/Sections/Games.png
new file mode 100644 (file)
index 0000000..6e0efaf
Binary files /dev/null and b/Cydia.app/Sections/Games.png differ
diff --git a/Cydia.app/Sections/Java.png b/Cydia.app/Sections/Java.png
new file mode 100644 (file)
index 0000000..4b543db
Binary files /dev/null and b/Cydia.app/Sections/Java.png differ
diff --git a/Cydia.app/Sections/Localization.png b/Cydia.app/Sections/Localization.png
new file mode 100644 (file)
index 0000000..2450175
Binary files /dev/null and b/Cydia.app/Sections/Localization.png differ
diff --git a/Cydia.app/Sections/Multimedia.png b/Cydia.app/Sections/Multimedia.png
new file mode 100644 (file)
index 0000000..07f20b6
Binary files /dev/null and b/Cydia.app/Sections/Multimedia.png differ
diff --git a/Cydia.app/Sections/Networking.png b/Cydia.app/Sections/Networking.png
new file mode 100644 (file)
index 0000000..ee1f0a1
Binary files /dev/null and b/Cydia.app/Sections/Networking.png differ
diff --git a/Cydia.app/Sections/Packaging.png b/Cydia.app/Sections/Packaging.png
new file mode 100644 (file)
index 0000000..c1b72a5
Binary files /dev/null and b/Cydia.app/Sections/Packaging.png differ
diff --git a/Cydia.app/Sections/Planet-iPhones Mods.png b/Cydia.app/Sections/Planet-iPhones Mods.png
new file mode 100644 (file)
index 0000000..e641970
Binary files /dev/null and b/Cydia.app/Sections/Planet-iPhones Mods.png differ
diff --git a/Cydia.app/Sections/Productivity.png b/Cydia.app/Sections/Productivity.png
new file mode 100644 (file)
index 0000000..943b8bd
Binary files /dev/null and b/Cydia.app/Sections/Productivity.png differ
diff --git a/Cydia.app/Sections/Repositories.png b/Cydia.app/Sections/Repositories.png
new file mode 100644 (file)
index 0000000..bed4a4a
Binary files /dev/null and b/Cydia.app/Sections/Repositories.png differ
diff --git a/Cydia.app/Sections/Scripting.png b/Cydia.app/Sections/Scripting.png
new file mode 100644 (file)
index 0000000..d020f71
Binary files /dev/null and b/Cydia.app/Sections/Scripting.png differ
diff --git a/Cydia.app/Sections/Security.png b/Cydia.app/Sections/Security.png
new file mode 100644 (file)
index 0000000..b091a84
Binary files /dev/null and b/Cydia.app/Sections/Security.png differ
diff --git a/Cydia.app/Sections/System.png b/Cydia.app/Sections/System.png
new file mode 100644 (file)
index 0000000..f16c216
Binary files /dev/null and b/Cydia.app/Sections/System.png differ
diff --git a/Cydia.app/Sections/Terminal Support.png b/Cydia.app/Sections/Terminal Support.png
new file mode 100644 (file)
index 0000000..864374c
Binary files /dev/null and b/Cydia.app/Sections/Terminal Support.png differ
diff --git a/Cydia.app/Sections/Text Editors.png b/Cydia.app/Sections/Text Editors.png
new file mode 100644 (file)
index 0000000..8176c27
Binary files /dev/null and b/Cydia.app/Sections/Text Editors.png differ
diff --git a/Cydia.app/Sections/Themes.png b/Cydia.app/Sections/Themes.png
new file mode 100644 (file)
index 0000000..f5b44db
Binary files /dev/null and b/Cydia.app/Sections/Themes.png differ
diff --git a/Cydia.app/Sections/Toys.png b/Cydia.app/Sections/Toys.png
new file mode 100644 (file)
index 0000000..88df4ab
Binary files /dev/null and b/Cydia.app/Sections/Toys.png differ
diff --git a/Cydia.app/Sections/Tweaks.png b/Cydia.app/Sections/Tweaks.png
new file mode 100644 (file)
index 0000000..14d400b
Binary files /dev/null and b/Cydia.app/Sections/Tweaks.png differ
diff --git a/Cydia.app/Sections/Utilities.png b/Cydia.app/Sections/Utilities.png
new file mode 100644 (file)
index 0000000..2d7c31d
Binary files /dev/null and b/Cydia.app/Sections/Utilities.png differ
diff --git a/Cydia.app/Sections/X Window.png b/Cydia.app/Sections/X Window.png
new file mode 100644 (file)
index 0000000..5b1b7f5
Binary files /dev/null and b/Cydia.app/Sections/X Window.png differ
diff --git a/Cydia.app/Security.png b/Cydia.app/Security.png
deleted file mode 100644 (file)
index b091a84..0000000
Binary files a/Cydia.app/Security.png and /dev/null differ
diff --git a/Cydia.app/Sources/apt.bigboss.us.com.png b/Cydia.app/Sources/apt.bigboss.us.com.png
new file mode 100644 (file)
index 0000000..8c79a38
Binary files /dev/null and b/Cydia.app/Sources/apt.bigboss.us.com.png differ
diff --git a/Cydia.app/Sources/apt.saurik.com.png b/Cydia.app/Sources/apt.saurik.com.png
new file mode 100644 (file)
index 0000000..f2bfcab
Binary files /dev/null and b/Cydia.app/Sources/apt.saurik.com.png differ
diff --git a/Cydia.app/Sources/iphone.hackndev.org.png b/Cydia.app/Sources/iphone.hackndev.org.png
new file mode 100644 (file)
index 0000000..1f701df
Binary files /dev/null and b/Cydia.app/Sources/iphone.hackndev.org.png differ
diff --git a/Cydia.app/Sources/iphonehe. b/Cydia.app/Sources/iphonehe.
new file mode 100644 (file)
index 0000000..b20263e
Binary files /dev/null and b/Cydia.app/Sources/iphonehe. differ
diff --git a/Cydia.app/Sources/modmyifone.com.png b/Cydia.app/Sources/modmyifone.com.png
new file mode 100644 (file)
index 0000000..a7ca470
Binary files /dev/null and b/Cydia.app/Sources/modmyifone.com.png differ
diff --git a/Cydia.app/Sources/repo.smxy.org.png b/Cydia.app/Sources/repo.smxy.org.png
new file mode 100644 (file)
index 0000000..26c9655
Binary files /dev/null and b/Cydia.app/Sources/repo.smxy.org.png differ
diff --git a/Cydia.app/Sources/urbanfanatics.com.png b/Cydia.app/Sources/urbanfanatics.com.png
new file mode 100644 (file)
index 0000000..9cf47c4
Binary files /dev/null and b/Cydia.app/Sources/urbanfanatics.com.png differ
diff --git a/Cydia.app/Sources/www.zodttd.com.png b/Cydia.app/Sources/www.zodttd.com.png
new file mode 100644 (file)
index 0000000..83a3b33
Binary files /dev/null and b/Cydia.app/Sources/www.zodttd.com.png differ
diff --git a/Cydia.app/System.png b/Cydia.app/System.png
deleted file mode 100644 (file)
index f16c216..0000000
Binary files a/Cydia.app/System.png and /dev/null differ
diff --git a/Cydia.app/Terminal Support.png b/Cydia.app/Terminal Support.png
deleted file mode 100644 (file)
index 864374c..0000000
Binary files a/Cydia.app/Terminal Support.png and /dev/null differ
diff --git a/Cydia.app/Text Editors.png b/Cydia.app/Text Editors.png
deleted file mode 100644 (file)
index 8176c27..0000000
Binary files a/Cydia.app/Text Editors.png and /dev/null differ
diff --git a/Cydia.app/Themes.png b/Cydia.app/Themes.png
deleted file mode 100644 (file)
index f5b44db..0000000
Binary files a/Cydia.app/Themes.png and /dev/null differ
diff --git a/Cydia.app/Toys.png b/Cydia.app/Toys.png
deleted file mode 100644 (file)
index 88df4ab..0000000
Binary files a/Cydia.app/Toys.png and /dev/null differ
diff --git a/Cydia.app/Tweaks.png b/Cydia.app/Tweaks.png
deleted file mode 100644 (file)
index 14d400b..0000000
Binary files a/Cydia.app/Tweaks.png and /dev/null differ
diff --git a/Cydia.app/Utilities.png b/Cydia.app/Utilities.png
deleted file mode 100644 (file)
index 2d7c31d..0000000
Binary files a/Cydia.app/Utilities.png and /dev/null differ
diff --git a/Cydia.app/X Window.png b/Cydia.app/X Window.png
deleted file mode 100644 (file)
index 5b1b7f5..0000000
Binary files a/Cydia.app/X Window.png and /dev/null differ
diff --git a/Cydia.app/error.html b/Cydia.app/error.html
new file mode 100644 (file)
index 0000000..f72240d
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-16"?>
+<html><head>
+    <title>Network Error</title>
+    <meta name="viewport" content="width=320, minimum-scale=1.0, maximum-scale=1.0"/>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+
+    <style>
+        body {
+            background: url(pinstripe.png);
+            display: table;
+            font-family: Helvetica;
+            height: 337px;
+            margin: 0;
+            text-shadow: rgba(255, 255, 255, 0.75) 1px 1px 0
+        }
+
+        div.page {
+            display: table-cell;
+            text-align: center;
+            margin: 0 auto;
+            vertical-align: middle;
+            width: 320px;
+        }
+
+        div.title {
+            font-size: 32px;
+        }
+
+        div.error {
+            font-size: 24px;
+        }
+    </style>
+</head><body><div class="page">
+
+<div class="title">Unable To Load</div>
+
+<div class="error">(<script>
+    document.write(decodeURI(location.search.substring(1)));
+</script>)</div>
+
+</div></body></html>
diff --git a/Cydia.app/home.html b/Cydia.app/home.html
deleted file mode 100644 (file)
index f72240d..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-16"?>
-<html><head>
-    <title>Network Error</title>
-    <meta name="viewport" content="width=320, minimum-scale=1.0, maximum-scale=1.0"/>
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-
-    <style>
-        body {
-            background: url(pinstripe.png);
-            display: table;
-            font-family: Helvetica;
-            height: 337px;
-            margin: 0;
-            text-shadow: rgba(255, 255, 255, 0.75) 1px 1px 0
-        }
-
-        div.page {
-            display: table-cell;
-            text-align: center;
-            margin: 0 auto;
-            vertical-align: middle;
-            width: 320px;
-        }
-
-        div.title {
-            font-size: 32px;
-        }
-
-        div.error {
-            font-size: 24px;
-        }
-    </style>
-</head><body><div class="page">
-
-<div class="title">Unable To Load</div>
-
-<div class="error">(<script>
-    document.write(decodeURI(location.search.substring(1)));
-</script>)</div>
-
-</div></body></html>
diff --git a/Cydia.app/manage.html b/Cydia.app/manage.html
new file mode 100644 (file)
index 0000000..ebda79a
--- /dev/null
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-16"?>
+<html><head>
+    <title>Manage</title>
+    <meta name="viewport" content="width=320, minimum-scale=1.0, maximum-scale=1.0"/>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+
+    <style>
+        body {
+            background: url(pinstripe.png);
+            display: table;
+            font-family: Helvetica;
+            height: 337px;
+            margin: 0;
+            padding: 0;
+            -webkit-text-size-adjust: none;
+            -webkit-user-select: none;
+        }
+
+        div.page {
+            display: table-cell;
+            text-align: center;
+            margin: 0 auto;
+            vertical-align: middle;
+            width: 320px;
+        }
+
+        a.giant-button {
+            color: #193250;
+            display: block;
+            margin: 10px;
+            text-decoration: none;
+        }
+
+        a.giant-button > div.contents {
+            position: absolute;
+            text-align: left;
+            width: 300px;
+            -webkit-background-size: 75px auto;
+            z-index: 2;
+        }
+
+        a.giant-button > div.contents > img {
+            float: left;
+            height: 80px;
+            margin: 10px;
+            width: 80px;
+            vertical-align: middle;
+        }
+
+        a.giant-button > div.contents > label {
+            display: block;
+            float: left;
+            font-size: 30px;
+            margin: 10px 0 4px 4px;
+            text-align: center;
+            text-shadow: rgba(200, 200, 200, 0.75) 1px 1px 0;
+            width: 180px;
+        }
+
+        a.giant-button > div.contents > div {
+            display: block;
+            float: left;
+            font-size: 14px;
+            margin-left: 4px;
+            text-align: center;
+            width: 180px;
+        }
+
+        a.giant-button > div.background {
+            background-color: #000000;
+            height: 98px;
+            opacity: 0.15;
+            -webkit-border-radius: 10px;
+        }
+    </style>
+</head><body><div class="page">
+<div class="dialog">
+    <div class="panel">
+
+<a href="cydia://packages" class="giant-button">
+    <div class="contents">
+        <img src="packages.png"/>
+        <label>Packages</label>
+        <div>View or remove packages you previously installed.</div>
+    </div>
+
+    <div class="background"></div>
+</a>
+
+<a href="cydia://sources" class="giant-button">
+    <div class="contents">
+        <img src="sources.png"/>
+        <label>Sources</label>
+        <div>List current sources and add custom ones you may know.</div>
+    </div>
+
+    <div class="background"></div>
+</a>
+
+<a href="cydia://storage" class="giant-button" style="opacity: 0.4">
+    <div class="contents">
+        <img src="storage.png" class="icon"/>
+        <label>Storage</label>
+        <div>See how much room you have left for new packages.</div>
+    </div>
+
+    <div class="background"></div>
+</a>
+
+    <div style="position: absolute; top: 256px; color: red; margin: 0 auto; font-size: 40px; height: 40px; width: 320px; -webkit-transform:rotate(-10deg); text-shadow: rgba(250, 150, 150, 0.75) 1px 1px 0">Coming Soon!</div>
+
+    </div>
+</div>
+</div></body></html>
diff --git a/Cydia.app/packages.png b/Cydia.app/packages.png
new file mode 100644 (file)
index 0000000..404fe0c
Binary files /dev/null and b/Cydia.app/packages.png differ
diff --git a/Cydia.app/sections.txt b/Cydia.app/sections.txt
new file mode 100644 (file)
index 0000000..423c164
--- /dev/null
@@ -0,0 +1 @@
+Tweaks_2.0 Tweaks
diff --git a/Cydia.app/sources.png b/Cydia.app/sources.png
new file mode 100644 (file)
index 0000000..e8422e4
Binary files /dev/null and b/Cydia.app/sources.png differ
diff --git a/Cydia.app/storage.png b/Cydia.app/storage.png
new file mode 100644 (file)
index 0000000..3cefef0
Binary files /dev/null and b/Cydia.app/storage.png differ
index c48c68b008307b7a0a755f4a1090eb8d1d819663..64071267f88d5848ccf20a3959148fbe3018dc22 100644 (file)
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -40,6 +40,7 @@
     #define textTraits textInputTraits
     #define setAutoCapsType setAutocapitalizationType
     #define setAutoCorrectionType setAutocorrectionType
+    #define setPreferredKeyboardType setKeyboardType
 #endif
 
 /* #include Directives {{{ */
@@ -267,8 +268,6 @@ class Pcre {
 };
 /* }}} */
 /* Mime Addresses {{{ */
-Pcre email_r("^\"?(.*)\"? <([^>]*)>$");
-
 @interface Address : NSObject {
     NSString *name_;
     NSString *email_;
@@ -307,6 +306,8 @@ Pcre email_r("^\"?(.*)\"? <([^>]*)>$");
         const char *data = [string UTF8String];
         size_t size = [string length];
 
+        static Pcre email_r("^\"?(.*)\"? <([^>]*)>$");
+
         if (email_r(data, size)) {
             name_ = [email_r[1] retain];
             email_ = [email_r[2] retain];
@@ -429,6 +430,7 @@ static CGColor Black_;
 static CGColor Clear_;
 static CGColor Red_;
 static CGColor White_;
+static CGColor Gray_;
 
 static NSString *Home_;
 static BOOL Sounds_Keyboard_;
@@ -456,9 +458,13 @@ CGColorSpaceRef space_;
 bool bootstrap_;
 bool reload_;
 
+static NSMutableDictionary *SectionMap_;
 static NSMutableDictionary *Metadata_;
-static NSMutableDictionary *Packages_;
-static NSMutableDictionary *Sections_;
+static _transient NSMutableDictionary *Settings_;
+static _transient NSString *Role_;
+static _transient NSMutableDictionary *Packages_;
+static _transient NSMutableDictionary *Sections_;
+static _transient NSMutableDictionary *Sources_;
 static bool Changed_;
 static NSDate *now_;
 
@@ -527,11 +533,19 @@ NSString *Simplify(NSString *title) {
     const char *data = [title UTF8String];
     size_t size = [title length];
 
-    Pcre title_r("^(.*?)( \\(.*\\))?$");
+    static Pcre square_r("^\\[(.*)\\]$");
+    if (square_r(data, size))
+        return Simplify(square_r[1]);
+
+    static Pcre paren_r("^\\((.*)\\)$");
+    if (paren_r(data, size))
+        return Simplify(paren_r[1]);
+
+    static Pcre title_r("^(.*?) \\(.*\\)$");
     if (title_r(data, size))
-        return title_r[1];
-    else
-        return title;
+        return Simplify(title_r[1]);
+
+    return title;
 }
 /* }}} */
 
@@ -577,6 +591,9 @@ bool isSectionVisible(NSString *section) {
 - (void) slideUp:(UIAlertSheet *)alert;
 - (void) distUpgrade;
 - (void) updateData;
+- (void) syncData;
+- (void) askForSettings;
+- (UIProgressHUD *) addProgressHUD;
 @end
 /* }}} */
 
@@ -710,6 +727,7 @@ class Progress :
 - (pkgProblemResolver *) resolver;
 - (pkgAcquire &) fetcher;
 - (NSArray *) packages;
+- (NSArray *) sources;
 - (void) reloadData;
 
 - (void) configure;
@@ -738,23 +756,31 @@ class Progress :
 
     NSString *defaultIcon_;
 
+    NSDictionary *record_;
     BOOL trusted_;
 }
 
 - (Source *) initWithMetaIndex:(metaIndex *)index;
 
+- (NSComparisonResult) compareByNameAndType:(Source *)source;
+
+- (NSDictionary *) record;
 - (BOOL) trusted;
 
 - (NSString *) uri;
 - (NSString *) distribution;
 - (NSString *) type;
+- (NSString *) key;
+- (NSString *) host;
 
+- (NSString *) name;
 - (NSString *) description;
 - (NSString *) label;
 - (NSString *) origin;
 - (NSString *) version;
 
 - (NSString *) defaultIcon;
+
 @end
 
 @implementation Source
@@ -774,6 +800,8 @@ class Progress :
         [version_ release];
     if (defaultIcon_ != nil)
         [defaultIcon_ release];
+    if (record_ != nil)
+        [record_ release];
 
     [super dealloc];
 }
@@ -818,9 +846,40 @@ class Progress :
                     version_ = [[NSString stringWithUTF8String:value.c_str()] retain];
             }
         }
+
+        record_ = [Sources_ objectForKey:[self key]];
+        if (record_ != nil)
+            record_ = [record_ retain];
     } return self;
 }
 
+- (NSComparisonResult) compareByNameAndType:(Source *)source {
+    NSDictionary *lhr = [self record];
+    NSDictionary *rhr = [source record];
+
+    if (lhr != rhr)
+        return lhr == nil ? NSOrderedDescending : NSOrderedAscending;
+
+    NSString *lhs = [self name];
+    NSString *rhs = [source name];
+
+    if ([lhs length] != 0 && [rhs length] != 0) {
+        unichar lhc = [lhs characterAtIndex:0];
+        unichar rhc = [rhs characterAtIndex:0];
+
+        if (isalpha(lhc) && !isalpha(rhc))
+            return NSOrderedAscending;
+        else if (!isalpha(lhc) && isalpha(rhc))
+            return NSOrderedDescending;
+    }
+
+    return [lhs caseInsensitiveCompare:rhs];
+}
+
+- (NSDictionary *) record {
+    return record_;
+}
+
 - (BOOL) trusted {
     return trusted_;
 }
@@ -837,12 +896,24 @@ class Progress :
     return type_;
 }
 
+- (NSString *) key {
+    return [NSString stringWithFormat:@"%@:%@:%@", type_, uri_, distribution_];
+}
+
+- (NSString *) host {
+    return [[[NSURL URLWithString:[self uri]] host] lowercaseString];
+}
+
+- (NSString *) name {
+    return origin_ == nil ? [self host] : origin_;
+}
+
 - (NSString *) description {
     return description_;
 }
 
 - (NSString *) label {
-    return label_;
+    return label_ == nil ? [self host] : label_;
 }
 
 - (NSString *) origin {
@@ -944,6 +1015,7 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     Address *sponsor_;
     Address *author_;
     NSArray *tags_;
+    NSString *role_;
 
     NSArray *relationships_;
 }
@@ -986,10 +1058,11 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
 - (NSArray *) relationships;
 
 - (Source *) source;
+- (NSString *) role;
 
 - (BOOL) matches:(NSString *)text;
 
-- (bool) hasUsefulPurpose;
+- (bool) hasSupportingRole;
 - (BOOL) hasTag:(NSString *)tag;
 
 - (NSComparisonResult) compareByName:(Package *)package;
@@ -1000,9 +1073,10 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
 - (void) install;
 - (void) remove;
 
-- (NSNumber *) isSearchedForBy:(NSString *)search;
+- (NSNumber *) isVisiblySearchedForBy:(NSString *)search;
 - (NSNumber *) isInstalledInSection:(NSString *)section;
-- (NSNumber *) isUninstalledInSection:(NSString *)section;
+- (NSNumber *) isVisiblyUninstalledInSection:(NSString *)section;
+- (NSNumber *) isVisibleInSource:(Source *)source;
 
 @end
 
@@ -1030,6 +1104,8 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
         [author_ release];
     if (tags_ != nil)
         [tags_ release];
+    if (role_ != nil)
+        [role_ release];
 
     if (relationships_ != nil)
         [relationships_ release];
@@ -1086,6 +1162,15 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
                 tags_ = [[tags componentsSeparatedByString:@", "] retain];
         }
 
+        if (tags_ != nil)
+            for (int i(0), e([tags_ count]); i != e; ++i) {
+                NSString *tag = [tags_ objectAtIndex:i];
+                if ([tag hasPrefix:@"role::"]) {
+                    role_ = [[tag substringFromIndex:6] retain];
+                    break;
+                }
+            }
+
         NSMutableDictionary *metadata = [Packages_ objectForKey:id_];
         if (metadata == nil || [metadata count] == 0) {
             metadata = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@@ -1111,7 +1196,13 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
 
 - (NSString *) section {
     const char *section = iterator_.Section();
-    return section == NULL ? nil : [[NSString stringWithUTF8String:section] stringByReplacingCharacter:'_' withCharacter:' '];
+    if (section == NULL)
+        return nil;
+    NSString *key = [[NSString stringWithUTF8String:section] stringByReplacingCharacter:' ' withCharacter:'_'];
+    NSString *value = [SectionMap_ objectForKey:key];
+    if (value == nil)
+        value = key;
+    return [value stringByReplacingCharacter:'_' withCharacter:' '];
 }
 
 - (Address *) maintainer {
@@ -1187,7 +1278,7 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
 
 - (BOOL) visible {
     NSString *section = [self section];
-    return [self hasUsefulPurpose] && (section == nil || isSectionVisible(section));
+    return [self hasSupportingRole] && (section == nil || isSectionVisible(section));
 }
 
 - (BOOL) half {
@@ -1285,6 +1376,10 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     return source_;
 }
 
+- (NSString *) role {
+    return role_;
+}
+
 - (BOOL) matches:(NSString *)text {
     if (text == nil)
         return NO;
@@ -1306,27 +1401,22 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     return NO;
 }
 
-- (bool) hasUsefulPurpose {
-    if (tags_ == nil)
+- (bool) hasSupportingRole {
+    if (role_ == nil)
         return true;
-    bool purpose(false);
-
-    for (int i(0), e([tags_ count]); i != e; ++i) {
-        NSString *tag = [tags_ objectAtIndex:i];
-        if ([tag hasPrefix:@"purpose::"]) {
-            bool purpose(false);
-            if ([tag isEqualToString:@"purpose::console"]) {
-                return true;
-            } else if ([tag isEqualToString:@"purpose::library"]) {
-                return true;
-            } else if ([tag isEqualToString:@"purpose::x"]) {
-                return true;
-            } else
-                purpose = true;
-        }
-    }
-
-    return !purpose;
+    if ([role_ isEqualToString:@"enduser"])
+        return true;
+    if ([Role_ isEqualToString:@"User"])
+        return false;
+    if ([role_ isEqualToString:@"hacker"])
+        return true;
+    if ([Role_ isEqualToString:@"Hacker"])
+        return false;
+    if ([role_ isEqualToString:@"developer"])
+        return true;
+    if ([Role_ isEqualToString:@"Developer"])
+        return false;
+    _assert(false);
 }
 
 - (BOOL) hasTag:(NSString *)tag {
@@ -1425,22 +1515,29 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     [database_ cache]->MarkDelete(iterator_, true);
 }
 
-- (NSNumber *) isSearchedForBy:(NSString *)search {
-    return [NSNumber numberWithBool:([self valid] && [self matches:search])];
+- (NSNumber *) isVisiblySearchedForBy:(NSString *)search {
+    return [NSNumber numberWithBool:([self valid] && [self visible] && [self matches:search])];
 }
 
 - (NSNumber *) isInstalledInSection:(NSString *)section {
     return [NSNumber numberWithBool:([self installed] != nil && (section == nil || [section isEqualToString:[self section]]))];
 }
 
-- (NSNumber *) isUninstalledInSection:(NSString *)name {
+- (NSNumber *) isVisiblyUninstalledInSection:(NSString *)name {
     NSString *section = [self section];
 
-    return [NSNumber numberWithBool:([self valid] && [self installed] == nil && (
-        (name == nil && [self visible] ||
-        section == nil && [name length] == 0 ||
-        [name isEqualToString:section])
-    ))];
+    return [NSNumber numberWithBool:(
+        [self valid] && [self visible] &&
+        [self installed] == nil && (
+            name == nil ||
+            section == nil && [name length] == 0 ||
+            [name isEqualToString:section]
+        )
+    )];
+}
+
+- (NSNumber *) isVisibleInSource:(Source *)source {
+    return [NSNumber numberWithBool:([self source] == source && [self visible])];
 }
 
 @end
@@ -1548,8 +1645,8 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     std::istream is(&ib);
     std::string line;
 
-    Pcre conffile_r("^status: [^ ]* : conffile-prompt : (.*?) *$");
-    Pcre pmstatus_r("^([^:]*):([^:]*):([^:]*):(.*)$");
+    static Pcre conffile_r("^status: [^ ]* : conffile-prompt : (.*?) *$");
+    static Pcre pmstatus_r("^([^:]*):([^:]*):([^:]*):(.*)$");
 
     while (std::getline(is, line)) {
         const char *data(line.c_str());
@@ -1690,6 +1787,10 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     return packages_;
 }
 
+- (NSArray *) sources {
+    return [sources_ allValues];
+}
+
 - (void) reloadData {
     _error->Discard();
 
@@ -2256,8 +2357,6 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
 @end
 /* }}} */
 /* Progress View {{{ */
-Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
-
 @interface ProgressView : UIView <
     ConfigurationDelegate,
     ProgressDelegate
@@ -2403,7 +2502,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
         [close_ setAutosizesToFit:NO];
         [close_ setDrawsShadow:YES];
         [close_ setStretchBackground:YES];
-        [close_ setTitle:@"Close Window"];
+        [close_ setTitle:@"Return to Cydia"];
         [close_ setEnabled:YES];
 
         GSFontRef bold = GSFontCreateWithName("Helvetica", kGSFontTraitBold, 22);
@@ -2564,6 +2663,8 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
 }
 
 - (void) _setConfigurationData:(NSString *)data {
+    static Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
+
     _assert(conffile_r(data));
 
     NSString *ofile = conffile_r[1];
@@ -2627,11 +2728,6 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
 - (PackageCell *) init;
 - (void) setPackage:(Package *)package;
 
-- (void) _setSelected:(float)fraction;
-- (void) setSelected:(BOOL)selected;
-- (void) setSelected:(BOOL)selected withFade:(BOOL)fade;
-- (void) _setSelectionFadeFraction:(float)fraction;
-
 + (int) heightForPackage:(Package *)package;
 
 @end
@@ -2653,7 +2749,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
 
 - (PackageCell *) init {
     if ((self = [super init]) != nil) {
-        GSFontRef bold = GSFontCreateWithName("Helvetica", kGSFontTraitBold, 20);
+        GSFontRef bold = GSFontCreateWithName("Helvetica", kGSFontTraitBold, 18);
         GSFontRef large = GSFontCreateWithName("Helvetica", kGSFontTraitNone, 12);
         GSFontRef small = GSFontCreateWithName("Helvetica", kGSFontTraitNone, 14);
 
@@ -2663,7 +2759,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
         [name_ setBackgroundColor:Clear_];
         [name_ setFont:bold];
 
-        source_ = [[UITextLabel alloc] initWithFrame:CGRectMake(58, 28, 225, 20)];
+        source_ = [[UITextLabel alloc] initWithFrame:CGRectMake(58, 27, 225, 20)];
         [source_ setBackgroundColor:Clear_];
         [source_ setFont:large];
 
@@ -2682,10 +2778,6 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
         [status_ setFont:small];
 #endif
 
-        /*[icon_ setImage:[UIImage applicationImageNamed:@"unknown.png"]];
-        [icon_ zoomToScale:0.5];
-        [icon_ setFrame:CGRectMake(10, 10, 30, 30)];*/
-
         [self addSubview:icon_];
         [self addSubview:name_];
         [self addSubview:description_];
@@ -2709,7 +2801,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     if (NSString *icon = [package icon])
         image = [UIImage imageAtPath:[icon substringFromIndex:6]];
     if (image == nil) if (NSString *section = [package section])
-        image = [UIImage applicationImageNamed:[Simplify(section) stringByAppendingString:@".png"]];
+        image = [UIImage applicationImageNamed:[NSString stringWithFormat:@"Sections/%@.png", Simplify(section)]];
     /*if (image == nil) if (NSString *icon = [source defaultIcon])
         image = [UIImage imageAtPath:[icon substringFromIndex:6]];*/
     if (image == nil)
@@ -2735,8 +2827,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
         trusted = [source trusted];
     } else if ([[package id] isEqualToString:@"firmware"])
         label = @"Apple";
-
-    if (label == nil)
+    else
         label = @"Unknown/Local";
 
     NSString *from = [NSString stringWithFormat:@"from %@", label];
@@ -2833,11 +2924,6 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
 - (id) init;
 - (void) setSection:(Section *)section editing:(BOOL)editing;
 
-- (void) _setSelected:(float)fraction;
-- (void) setSelected:(BOOL)selected;
-- (void) setSelected:(BOOL)selected withFade:(BOOL)fade;
-- (void) _setSelectionFadeFraction:(float)fraction;
-
 @end
 
 @implementation SectionCell
@@ -2851,6 +2937,32 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     [super dealloc];
 }
 
+- (void) _setSelected:(float)fraction {
+    CGColor black(space_,
+        Interpolate(0.0, 1.0, fraction),
+        Interpolate(0.0, 1.0, fraction),
+        Interpolate(0.0, 1.0, fraction),
+    1.0);
+
+    [name_ setColor:black];
+}
+
+- (void) setSelected:(BOOL)selected {
+    [self _setSelected:(selected ? 1.0 : 0.0)];
+    [super setSelected:selected];
+}
+
+- (void) setSelected:(BOOL)selected withFade:(BOOL)fade {
+    if (!fade)
+        [self _setSelected:(selected ? 1.0 : 0.0)];
+    [super setSelected:selected withFade:fade];
+}
+
+- (void) _setSelectionFadeFraction:(float)fraction {
+    [self _setSelected:fraction];
+    [super _setSelectionFadeFraction:fraction];
+}
+
 - (id) init {
     if ((self = [super init]) != nil) {
         GSFontRef bold = GSFontCreateWithName("Helvetica", kGSFontTraitBold, 22);
@@ -2925,32 +3037,6 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     [name_ setFrame:CGRectMake(48, 9, editing_ ? 165 : 250, 25)];
 }
 
-- (void) _setSelected:(float)fraction {
-    CGColor black(space_,
-        Interpolate(0.0, 1.0, fraction),
-        Interpolate(0.0, 1.0, fraction),
-        Interpolate(0.0, 1.0, fraction),
-    1.0);
-
-    [name_ setColor:black];
-}
-
-- (void) setSelected:(BOOL)selected {
-    [self _setSelected:(selected ? 1.0 : 0.0)];
-    [super setSelected:selected];
-}
-
-- (void) setSelected:(BOOL)selected withFade:(BOOL)fade {
-    if (!fade)
-        [self _setSelected:(selected ? 1.0 : 0.0)];
-    [super setSelected:selected withFade:fade];
-}
-
-- (void) _setSelectionFadeFraction:(float)fraction {
-    [self _setSelected:fraction];
-    [super _setSelectionFadeFraction:fraction];
-}
-
 @end
 /* }}} */
 
@@ -3649,148 +3735,813 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
 @end
 /* }}} */
 
-/* Browser Implementation {{{ */
-@implementation BrowserView
-
-- (void) dealloc {
-    WebView *webview = [webview_ webView];
-    [webview setFrameLoadDelegate:nil];
-    [webview setResourceLoadDelegate:nil];
-    [webview setUIDelegate:nil];
-
-    [scroller_ setDelegate:nil];
-    [webview_ setDelegate:nil];
-
-    [scroller_ release];
-    [webview_ release];
-    [urls_ release];
-    [indicator_ release];
-    if (title_ != nil)
-        [title_ release];
-    [super dealloc];
+/* Add Source View {{{ */
+@interface AddSourceView : RVPage {
+    _transient Database *database_;
 }
 
-- (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy {
-    NSMutableURLRequest *request = [NSMutableURLRequest
-        requestWithURL:url
-        cachePolicy:policy
-        timeoutInterval:30.0
-    ];
-
-    [request addValue:[NSString stringWithUTF8String:Firmware_] forHTTPHeaderField:@"X-Firmware"];
-    [request addValue:[NSString stringWithUTF8String:Machine_] forHTTPHeaderField:@"X-Machine"];
-    [request addValue:[NSString stringWithUTF8String:SerialNumber_] forHTTPHeaderField:@"X-Serial-Number"];
+- (id) initWithBook:(RVBook *)book database:(Database *)database;
 
-    [self loadRequest:request];
-}
+@end
 
+@implementation AddSourceView
 
-- (void) loadURL:(NSURL *)url {
-    [self loadURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy];
+- (id) initWithBook:(RVBook *)book database:(Database *)database {
+    if ((self = [super initWithBook:book]) != nil) {
+        database_ = database;
+    } return self;
 }
 
-// XXX: this needs to add the headers
-- (NSURLRequest *) _addHeadersToRequest:(NSURLRequest *)request {
-    return request;
+@end
+/* }}} */
+/* Source Cell {{{ */
+@interface SourceCell : UITableCell {
+    UIImageView *icon_;
+    UITextLabel *origin_;
+    UITextLabel *description_;
+    UITextLabel *label_;
 }
 
-- (void) loadRequest:(NSURLRequest *)request {
-    pushed_ = true;
-    [webview_ loadRequest:request];
-}
+- (void) dealloc;
 
-- (void) reloadURL {
-    NSURL *url = [[[urls_ lastObject] retain] autorelease];
-    [urls_ removeLastObject];
-    [self loadURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData];
-}
+- (SourceCell *) initWithSource:(Source *)source;
 
-- (WebView *) webView {
-    return [webview_ webView];
-}
+@end
 
-- (void) view:(UIView *)sender didSetFrame:(CGRect)frame {
-    [scroller_ setContentSize:frame.size];
-}
+@implementation SourceCell
 
-- (void) view:(UIView *)sender didSetFrame:(CGRect)frame oldFrame:(CGRect)old {
-    [self view:sender didSetFrame:frame];
+- (void) dealloc {
+    [origin_ release];
+    [description_ release];
+    [label_ release];
+    [super dealloc];
 }
 
-- (void) getAppTapp:(NSString *)href {
-    if ([href hasPrefix:@"apptapp://package/"]) {
-        NSString *name = [href substringFromIndex:18];
-        Package *package = [database_ packageWithName:name];
-        if (package == nil) {
-            UIAlertSheet *sheet = [[[UIAlertSheet alloc]
-                initWithTitle:@"Cannot Locate Package"
-                buttons:[NSArray arrayWithObjects:@"Close", nil]
-                defaultButtonIndex:0
-                delegate:self
-                context:@"missing"
-            ] autorelease];
-
-            [sheet setBodyText:[NSString stringWithFormat:
-                @"The package %@ cannot be found in your current sources. I might recommend installing more sources."
-            , name]];
+- (SourceCell *) initWithSource:(Source *)source {
+    if ((self = [super init]) != nil) {
+        GSFontRef bold = GSFontCreateWithName("Helvetica", kGSFontTraitBold, 18);
+        GSFontRef large = GSFontCreateWithName("Helvetica", kGSFontTraitNone, 12);
+        GSFontRef small = GSFontCreateWithName("Helvetica", kGSFontTraitNone, 14);
 
-            [sheet popupAlertAnimated:YES];
-        } else {
-            [self setBackButtonTitle:title_];
-            PackageView *view = [[[PackageView alloc] initWithBook:book_ database:database_] autorelease];
-            [view setDelegate:delegate_];
-            [view setPackage:package];
-            [book_ pushPage:view];
-        }
-    }
-}
+        icon_ = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 30, 30)];
 
-- (void) webView:(WebView *)sender willClickElement:(id)element {
-    if (![element respondsToSelector:@selector(href)])
-        return;
-    NSString *href = [element href];
-    if (href == nil)
-        return;
-    if ([href hasPrefix:@"apptapp://package/"])
-        [self getAppTapp:href];
-}
+        UIImage *image = nil;
+        if (image == nil)
+            image = [UIImage applicationImageNamed:[NSString stringWithFormat:@"Sources/%@.png", [source host]]];
+        if (image == nil)
+            image = [UIImage applicationImageNamed:@"unknown.png"];
 
-- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource {
-    if ([[[request URL] scheme] isEqualToString:@"apptapp"]) {
-        [self getAppTapp:[[request URL] absoluteString]];
-        return nil;
-    }
+        [icon_ setImage:image];
+        [icon_ zoomToScale:0.5];
+        [icon_ setFrame:CGRectMake(10, 10, 30, 30)];
 
-    if (!pushed_) {
-        pushed_ = true;
-        [book_ pushPage:self];
-    }
+        origin_ = [[UITextLabel alloc] initWithFrame:CGRectMake(48, 8, 240, 25)];
+        [origin_ setBackgroundColor:Clear_];
+        [origin_ setFont:bold];
 
-    return [self _addHeadersToRequest:request];
-}
+        label_ = [[UITextLabel alloc] initWithFrame:CGRectMake(58, 27, 225, 20)];
+        [label_ setBackgroundColor:Clear_];
+        [label_ setFont:large];
 
-- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request {
-    if (request != nil && [[[request URL] scheme] isEqualToString:@"apptapp"])
-        return nil;
-    else {
-        [self setBackButtonTitle:title_];
+        description_ = [[UITextLabel alloc] initWithFrame:CGRectMake(12, 46, 280, 20)];
+        [description_ setBackgroundColor:Clear_];
+        [description_ setFont:small];
 
-        BrowserView *browser = [[[BrowserView alloc] initWithBook:book_ database:database_] autorelease];
-        [browser setDelegate:delegate_];
+        [origin_ setText:[source name]];
+        [label_ setText:[source uri]];
+        [description_ setText:[source description]];
 
-        if (request != nil) {
-            [browser loadRequest:[self _addHeadersToRequest:request]];
-            [book_ pushPage:browser];
-        }
+        [self addSubview:icon_];
+        [self addSubview:origin_];
+        [self addSubview:description_];
+        [self addSubview:label_];
 
-        return [browser webView];
-    }
+        CFRelease(small);
+        CFRelease(bold);
+    } return self;
 }
 
-- (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
-    title_ = [title retain];
-    [self setTitle:title];
-}
+- (void) _setSelected:(float)fraction {
+    CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
+
+    float black[] = {
+        Interpolate(0.0, 1.0, fraction),
+        Interpolate(0.0, 1.0, fraction),
+        Interpolate(0.0, 1.0, fraction),
+    1.0};
+
+    float blue[] = {
+        Interpolate(0.2, 1.0, fraction),
+        Interpolate(0.2, 1.0, fraction),
+        Interpolate(1.0, 1.0, fraction),
+    1.0};
+
+    float gray[] = {
+        Interpolate(0.4, 1.0, fraction),
+        Interpolate(0.4, 1.0, fraction),
+        Interpolate(0.4, 1.0, fraction),
+    1.0};
+
+    [origin_ setColor:CGColorCreate(space, black)];
+    [label_ setColor:CGColorCreate(space, blue)];
+    [description_ setColor:CGColorCreate(space, gray)];
+}
+
+- (void) setSelected:(BOOL)selected {
+    [self _setSelected:(selected ? 1.0 : 0.0)];
+    [super setSelected:selected];
+}
+
+- (void) setSelected:(BOOL)selected withFade:(BOOL)fade {
+    if (!fade)
+        [self _setSelected:(selected ? 1.0 : 0.0)];
+    [super setSelected:selected withFade:fade];
+}
+
+- (void) _setSelectionFadeFraction:(float)fraction {
+    [self _setSelected:fraction];
+    [super _setSelectionFadeFraction:fraction];
+}
+
+@end
+/* }}} */
+/* Source Table {{{ */
+@interface SourceTable : RVPage {
+    _transient Database *database_;
+    UISectionList *list_;
+    NSMutableArray *sources_;
+    UIAlertSheet *alert_;
+    int offset_;
+
+    NSString *href_;
+    UIProgressHUD *hud_;
+    NSError *error_;
+
+    //NSURLConnection *installer_;
+    NSURLConnection *trivial_bz2_;
+    NSURLConnection *trivial_gz_;
+    //NSURLConnection *automatic_;
+
+    BOOL trivial_;
+}
+
+- (id) initWithBook:(RVBook *)book database:(Database *)database;
+
+@end
+
+@implementation SourceTable
+
+- (void) _deallocConnection:(NSURLConnection *)connection {
+    if (connection != nil) {
+        [connection cancel];
+        //[connection setDelegate:nil];
+        [connection release];
+    }
+}
+
+- (void) dealloc {
+    [[list_ table] setDelegate:nil];
+    [list_ setDataSource:nil];
+
+    if (href_ != nil)
+        [href_ release];
+    if (hud_ != nil)
+        [hud_ release];
+    if (error_ != nil)
+        [error_ release];
+
+    //[self _deallocConnection:installer_];
+    [self _deallocConnection:trivial_gz_];
+    [self _deallocConnection:trivial_bz2_];
+    //[self _deallocConnection:automatic_];
+
+    [sources_ release];
+    [list_ release];
+    [super dealloc];
+}
+
+- (int) numberOfSectionsInSectionList:(UISectionList *)list {
+    return offset_ == 0 ? 1 : 2;
+}
+
+- (NSString *) sectionList:(UISectionList *)list titleForSection:(int)section {
+    switch (section + (offset_ == 0 ? 1 : 0)) {
+        case 0: return @"Entered by User";
+        case 1: return @"Installed by Packages";
+
+        default:
+            _assert(false);
+            return nil;
+    }
+}
+
+- (int) sectionList:(UISectionList *)list rowForSection:(int)section {
+    switch (section + (offset_ == 0 ? 1 : 0)) {
+        case 0: return 0;
+        case 1: return offset_;
+
+        default:
+            _assert(false);
+            return -1;
+    }
+}
+
+- (int) numberOfRowsInTable:(UITable *)table {
+    return [sources_ count];
+}
+
+- (float) table:(UITable *)table heightForRow:(int)row {
+    Source *source = [sources_ objectAtIndex:row];
+    return [source description] == nil ? 58 : 73;
+}
+
+- (UITableCell *) table:(UITable *)table cellForRow:(int)row column:(UITableColumn *)col {
+    Source *source = [sources_ objectAtIndex:row];
+    // XXX: weird warning, stupid selectors ;P
+    return [[[SourceCell alloc] initWithSource:(id)source] autorelease];
+}
+
+- (BOOL) table:(UITable *)table showDisclosureForRow:(int)row {
+    return YES;
+}
+
+- (BOOL) table:(UITable *)table canSelectRow:(int)row {
+    return YES;
+}
+
+- (void) tableRowSelected:(NSNotification*)notification {
+    UITable *table([list_ table]);
+    int row([table selectedRow]);
+    if (row == INT_MAX)
+        return;
+
+    Source *source = [sources_ objectAtIndex:row];
+
+    PackageTable *packages = [[[PackageTable alloc]
+        initWithBook:book_
+        database:database_
+        title:[source label]
+        filter:@selector(isVisibleInSource:)
+        with:source
+    ] autorelease];
+
+    [packages setDelegate:delegate_];
+
+    [book_ pushPage:packages];
+}
+
+- (BOOL) table:(UITable *)table canDeleteRow:(int)row {
+    Source *source = [sources_ objectAtIndex:row];
+    return [source record] != nil;
+}
+
+- (void) table:(UITable *)table willSwipeToDeleteRow:(int)row {
+    [[list_ table] setDeleteConfirmationRow:row];
+}
+
+- (void) table:(UITable *)table deleteRow:(int)row {
+    Source *source = [sources_ objectAtIndex:row];
+    [Sources_ removeObjectForKey:[source key]];
+    [delegate_ syncData];
+}
+
+- (void) _endConnection:(NSURLConnection *)connection {
+    NSURLConnection **field = NULL;
+    if (connection == trivial_bz2_)
+        field = &trivial_bz2_;
+    else if (connection == trivial_gz_)
+        field = &trivial_gz_;
+    _assert(field != NULL);
+    [connection release];
+    *field = nil;
+
+    if (
+        trivial_bz2_ == nil &&
+        trivial_gz_ == nil
+    ) {
+        [delegate_ setStatusBarShowsProgress:NO];
+
+        [hud_ show:NO];
+        [hud_ removeFromSuperview];
+        [hud_ autorelease];
+        hud_ = nil;
+
+        if (trivial_) {
+            [Sources_ setObject:[NSDictionary dictionaryWithObjectsAndKeys:
+                @"deb", @"Type",
+                href_, @"URI",
+                @"./", @"Distribution",
+            nil] forKey:[NSString stringWithFormat:@"deb:%@:./", href_]];
+
+            [delegate_ syncData];
+        } else if (error_ != nil) {
+            UIAlertSheet *sheet = [[[UIAlertSheet alloc]
+                initWithTitle:@"Verification Error"
+                buttons:[NSArray arrayWithObjects:@"OK", nil]
+                defaultButtonIndex:0
+                delegate:self
+                context:@"urlerror"
+            ] autorelease];
+
+            [sheet setBodyText:[error_ localizedDescription]];
+            [sheet popupAlertAnimated:YES];
+        } else {
+            UIAlertSheet *sheet = [[[UIAlertSheet alloc]
+                initWithTitle:@"Did not Find Repository"
+                buttons:[NSArray arrayWithObjects:@"OK", nil]
+                defaultButtonIndex:0
+                delegate:self
+                context:@"trivial"
+            ] autorelease];
+
+            [sheet setBodyText:@"The indicated repository could not be found. This could be because you are trying to add a legacy Installer repository (these are not supported). Also, this interface is only capable of working with exact repository URLs. If you host a repository and are having issues please contact the author of Cydia with any questions you have."];
+            [sheet popupAlertAnimated:YES];
+        }
+
+        [href_ release];
+        href_ = nil;
+
+        if (error_ != nil) {
+            [error_ release];
+            error_ = nil;
+        }
+    }
+}
+
+- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)response {
+    switch ([response statusCode]) {
+        case 200:
+            trivial_ = YES;
+    }
+}
+
+- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
+    fprintf(stderr, "connection:\"%s\" didFailWithError:\"%s\"", [href_ UTF8String], [[error localizedDescription] UTF8String]);
+    if (error_ != nil)
+        error_ = [error retain];
+    [self _endConnection:connection];
+}
+
+- (void) connectionDidFinishLoading:(NSURLConnection *)connection {
+    [self _endConnection:connection];
+}
+
+- (NSURLConnection *) _requestHRef:(NSString *)href method:(NSString *)method {
+    NSMutableURLRequest *request = [NSMutableURLRequest
+        requestWithURL:[NSURL URLWithString:href]
+        cachePolicy:NSURLRequestUseProtocolCachePolicy
+        timeoutInterval:20.0
+    ];
+
+    [request setHTTPMethod:method];
+
+    return [[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];
+}
+
+- (void) alertSheet:(UIAlertSheet *)sheet buttonClicked:(int)button {
+    NSString *context = [sheet context];
+    if ([context isEqualToString:@"source"])
+        switch (button) {
+            case 1: {
+                NSString *href = [[sheet textField] text];
+
+                //installer_ = [[self _requestHRef:href method:@"GET"] retain];
+
+                if (![href hasSuffix:@"/"])
+                    href_ = [href stringByAppendingString:@"/"];
+                else
+                    href_ = href;
+                href_ = [href_ retain];
+
+                trivial_bz2_ = [[self _requestHRef:[href_ stringByAppendingString:@"Packages.bz2"] method:@"HEAD"] retain];
+                trivial_gz_ = [[self _requestHRef:[href_ stringByAppendingString:@"Packages.gz"] method:@"HEAD"] retain];
+                //trivial_bz2_ = [[self _requestHRef:[href stringByAppendingString:@"dists/Release"] method:@"HEAD"] retain];
+
+                trivial_ = false;
+
+                hud_ = [delegate_ addProgressHUD];
+                [hud_ setText:@"Verifying URL"];
+            } break;
+
+            case 2:
+            break;
+
+            default:
+                _assert(false);
+        }
+
+    [sheet dismiss];
+}
+
+- (id) initWithBook:(RVBook *)book database:(Database *)database {
+    if ((self = [super initWithBook:book]) != nil) {
+        database_ = database;
+        sources_ = [[NSMutableArray arrayWithCapacity:16] retain];
+
+        //list_ = [[UITable alloc] initWithFrame:[self bounds]];
+        list_ = [[UISectionList alloc] initWithFrame:[self bounds] showSectionIndex:NO];
+        [list_ setShouldHideHeaderInShortLists:NO];
+
+        [self addSubview:list_];
+        [list_ setDataSource:self];
+
+        UITableColumn *column = [[UITableColumn alloc]
+            initWithTitle:@"Name"
+            identifier:@"name"
+            width:[self frame].size.width
+        ];
+
+        UITable *table = [list_ table];
+        [table setSeparatorStyle:1];
+        [table addTableColumn:column];
+        [table setDelegate:self];
+
+        [self reloadData];
+    } return self;
+}
+
+- (void) reloadData {
+    pkgSourceList list;
+    _assert(list.ReadMainList());
+
+    [sources_ removeAllObjects];
+    [sources_ addObjectsFromArray:[database_ sources]];
+    [sources_ sortUsingSelector:@selector(compareByNameAndType:)];
+
+    int count = [sources_ count];
+    for (offset_ = 0; offset_ != count; ++offset_) {
+        Source *source = [sources_ objectAtIndex:offset_];
+        if ([source record] == nil)
+            break;
+    }
+
+    [list_ reloadData];
+}
+
+- (void) resetViewAnimated:(BOOL)animated {
+    [list_ resetViewAnimated:animated];
+}
+
+- (void) _leftButtonClicked {
+    /*[book_ pushPage:[[[AddSourceView alloc]
+        initWithBook:book_
+        database:database_
+    ] autorelease]];*/
+
+    UIAlertSheet *sheet = [[[UIAlertSheet alloc]
+        initWithTitle:@"Enter Cydia/APT URL"
+        buttons:[NSArray arrayWithObjects:@"Add Source", @"Cancel", nil]
+        defaultButtonIndex:0
+        delegate:self
+        context:@"source"
+    ] autorelease];
+
+    [sheet addTextFieldWithValue:@"http://" label:@""];
+
+    UITextTraits *traits = [[sheet textField] textTraits];
+    [traits setAutoCapsType:0];
+    [traits setPreferredKeyboardType:3];
+    [traits setAutoCorrectionType:1];
+
+    [sheet popupAlertAnimated:YES];
+}
+
+- (void) _rightButtonClicked {
+    UITable *table = [list_ table];
+    BOOL editing = [table isRowDeletionEnabled];
+    [table enableRowDeletion:!editing animated:YES];
+    [book_ reloadButtonsForPage:self];
+}
+
+- (NSString *) title {
+    return @"Sources";
+}
+
+- (NSString *) backButtonTitle {
+    return @"Sources";
+}
+
+- (NSString *) leftButtonTitle {
+    return [[list_ table] isRowDeletionEnabled] ? @"Add" : nil;
+}
+
+- (NSString *) rightButtonTitle {
+    return [[list_ table] isRowDeletionEnabled] ? @"Done" : @"Edit";
+}
+
+- (RVUINavBarButtonStyle) rightButtonStyle {
+    return [[list_ table] isRowDeletionEnabled] ? RVUINavBarButtonStyleHighlighted : RVUINavBarButtonStyleNormal;
+}
+
+@end
+/* }}} */
+
+/* Installed View {{{ */
+@interface InstalledView : RVPage {
+    _transient Database *database_;
+    PackageTable *packages_;
+}
+
+- (id) initWithBook:(RVBook *)book database:(Database *)database;
+
+@end
+
+@implementation InstalledView
+
+- (void) dealloc {
+    [packages_ release];
+    [super dealloc];
+}
+
+- (id) initWithBook:(RVBook *)book database:(Database *)database {
+    if ((self = [super initWithBook:book]) != nil) {
+        database_ = database;
+
+        packages_ = [[PackageTable alloc]
+            initWithBook:book
+            database:database
+            title:nil
+            filter:@selector(isInstalledInSection:)
+            with:nil
+        ];
+
+        [self addSubview:packages_];
+    } return self;
+}
+
+- (void) resetViewAnimated:(BOOL)animated {
+    [packages_ resetViewAnimated:animated];
+}
+
+- (void) reloadData {
+    [packages_ reloadData];
+}
+
+- (NSString *) title {
+    return @"Installed Packages";
+}
+
+- (NSString *) backButtonTitle {
+    return @"Packages";
+}
+
+- (void) setDelegate:(id)delegate {
+    [super setDelegate:delegate];
+    [packages_ setDelegate:delegate];
+}
+
+@end
+/* }}} */
+
+@interface HomeView : BrowserView {
+}
+
+@end
+
+@implementation HomeView
+
+- (void) alertSheet:(UIAlertSheet *)sheet buttonClicked:(int)button {
+    [sheet dismiss];
+}
+
+- (void) _leftButtonClicked {
+    UIAlertSheet *sheet = [[[UIAlertSheet alloc]
+        initWithTitle:@"About Cydia Installer"
+        buttons:[NSArray arrayWithObjects:@"Close", nil]
+        defaultButtonIndex:0
+        delegate:self
+        context:@"about"
+    ] autorelease];
+
+    [sheet setBodyText:
+        @"Copyright (C) 2008\n"
+        "Jay Freeman (saurik)\n"
+        "saurik@saurik.com\n"
+        "http://www.saurik.com/\n"
+        "\n"
+        "The Okori Group\n"
+        "http://www.theokorigroup.com/\n"
+        "\n"
+        "College of Creative Studies,\n"
+        "University of California,\n"
+        "Santa Barbara\n"
+        "http://www.ccs.ucsb.edu/"
+    ];
+
+    [sheet popupAlertAnimated:YES];
+}
+
+- (NSString *) leftButtonTitle {
+    return @"About";
+}
+
+@end
+
+@interface ManageView : BrowserView {
+}
+
+@end
+
+@implementation ManageView
+
+- (NSString *) title {
+    return @"Manage";
+}
+
+- (void) _leftButtonClicked {
+    [delegate_ askForSettings];
+}
+
+- (NSString *) leftButtonTitle {
+    return @"Settings";
+}
+
+- (NSString *) rightButtonTitle {
+    return nil;
+}
+
+@end
+
+/* Browser Implementation {{{ */
+@implementation BrowserView
+
+- (void) dealloc {
+    WebView *webview = [webview_ webView];
+    [webview setFrameLoadDelegate:nil];
+    [webview setResourceLoadDelegate:nil];
+    [webview setUIDelegate:nil];
+
+    [scroller_ setDelegate:nil];
+    [webview_ setDelegate:nil];
+
+    [scroller_ release];
+    [webview_ release];
+    [urls_ release];
+    [indicator_ release];
+    if (title_ != nil)
+        [title_ release];
+    [super dealloc];
+}
+
+- (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy {
+    [self loadRequest:[NSURLRequest
+        requestWithURL:url
+        cachePolicy:policy
+        timeoutInterval:30.0
+    ]];
+}
+
+- (void) loadURL:(NSURL *)url {
+    [self loadURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy];
+}
+
+- (NSURLRequest *) _addHeadersToRequest:(NSURLRequest *)request {
+    NSMutableURLRequest *copy = [request mutableCopy];
+
+    [copy addValue:[NSString stringWithUTF8String:Firmware_] forHTTPHeaderField:@"X-Firmware"];
+    [copy addValue:[NSString stringWithUTF8String:Machine_] forHTTPHeaderField:@"X-Machine"];
+    [copy addValue:[NSString stringWithUTF8String:SerialNumber_] forHTTPHeaderField:@"X-Serial-Number"];
+
+    if (Role_ != nil)
+        [copy addValue:Role_ forHTTPHeaderField:@"X-Role"];
+
+    return copy;
+}
+
+- (void) loadRequest:(NSURLRequest *)request {
+    pushed_ = true;
+    [webview_ loadRequest:request];
+}
+
+- (void) reloadURL {
+    NSURL *url = [[[urls_ lastObject] retain] autorelease];
+    [urls_ removeLastObject];
+    [self loadURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData];
+}
+
+- (WebView *) webView {
+    return [webview_ webView];
+}
+
+- (void) view:(UIView *)sender didSetFrame:(CGRect)frame {
+    [scroller_ setContentSize:frame.size];
+}
+
+- (void) view:(UIView *)sender didSetFrame:(CGRect)frame oldFrame:(CGRect)old {
+    [self view:sender didSetFrame:frame];
+}
+
+- (void) pushPage:(RVPage *)page {
+    [self setBackButtonTitle:title_];
+    [page setDelegate:delegate_];
+    [book_ pushPage:page];
+}
+
+- (void) getCydia:(NSString *)href {
+    RVPage *page = nil;
+
+    if ([href isEqualToString:@"cydia://add-source"])
+        page = [[[AddSourceView alloc] initWithBook:book_ database:database_] autorelease];
+    else if ([href isEqualToString:@"cydia://sources"])
+        page = [[[SourceTable alloc] initWithBook:book_ database:database_] autorelease];
+    else if ([href isEqualToString:@"cydia://packages"])
+        page = [[[InstalledView alloc] initWithBook:book_ database:database_] autorelease];
+
+    if (page != nil)
+        [self pushPage:page];
+}
+
+- (void) getAppTapp:(NSString *)href {
+    if ([href hasPrefix:@"apptapp://package/"]) {
+        NSString *name = [href substringFromIndex:18];
+        Package *package = [database_ packageWithName:name];
+        if (package == nil) {
+            UIAlertSheet *sheet = [[[UIAlertSheet alloc]
+                initWithTitle:@"Cannot Locate Package"
+                buttons:[NSArray arrayWithObjects:@"Close", nil]
+                defaultButtonIndex:0
+                delegate:self
+                context:@"missing"
+            ] autorelease];
+
+            [sheet setBodyText:[NSString stringWithFormat:
+                @"The package %@ cannot be found in your current sources. I might recommend installing more sources."
+            , name]];
+
+            [sheet popupAlertAnimated:YES];
+        } else {
+            PackageView *view = [[[PackageView alloc] initWithBook:book_ database:database_] autorelease];
+            [view setPackage:package];
+            [self pushPage:view];
+        }
+    }
+}
+
+- (void) webView:(WebView *)sender willClickElement:(id)element {
+    if ([[element localName] isEqualToString:@"img"])
+        do if ((element = [element parentNode]) == nil)
+            return;
+        while (![[element localName] isEqualToString:@"a"]);
+    if (![element respondsToSelector:@selector(href)])
+        return;
+    NSString *href = [element href];
+    if (href == nil)
+        return;
+    if ([href hasPrefix:@"cydia://"])
+        [self getCydia:href];
+    if ([href hasPrefix:@"apptapp://"])
+        [self getAppTapp:href];
+}
+
+- (NSURLRequest *) webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource {
+    NSString *scheme = [[request URL] scheme];
+
+    if ([scheme isEqualToString:@"apptapp"]) {
+        [self getAppTapp:[[request URL] absoluteString]];
+        return nil;
+    }
+
+    if ([scheme isEqualToString:@"cydia"]) {
+        [self getCydia:[[request URL] absoluteString]];
+        return nil;
+    }
+
+    if (!pushed_) {
+        pushed_ = true;
+        [book_ pushPage:self];
+    }
+
+    return [self _addHeadersToRequest:request];
+}
+
+- (WebView *) webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request {
+    if (request != nil) {
+        NSString *scheme = [[request URL] scheme];
+
+        if (
+            [scheme isEqualToString:@"apptapp"] ||
+            [scheme isEqualToString:@"cydia"]
+        )
+            return nil;
+    }
+
+    [self setBackButtonTitle:title_];
+
+    BrowserView *browser = [[[BrowserView alloc] initWithBook:book_ database:database_] autorelease];
+    [browser setDelegate:delegate_];
+
+    if (request != nil) {
+        [browser loadRequest:[self _addHeadersToRequest:request]];
+        [book_ pushPage:browser];
+    }
+
+    return [browser webView];
+}
+
+- (void) webView:(WebView *)sender didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame {
+    title_ = [title retain];
+    [self setTitle:title];
+}
 
 - (void) webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame {
     if ([frame parentFrame] != nil)
@@ -3835,8 +4586,9 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     if ([frame parentFrame] != nil)
         return;
     [self _finishLoading];
+
     [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
-        [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"home" ofType:@"html"]] absoluteString],
+        [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],
         [[error localizedDescription] stringByAddingPercentEscapes]
     ]]];
 }
@@ -3894,46 +4646,11 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     } return self;
 }
 
-- (void) alertSheet:(UIAlertSheet *)sheet buttonClicked:(int)button {
-    [sheet dismiss];
-}
-
-- (void) _leftButtonClicked {
-    UIAlertSheet *sheet = [[[UIAlertSheet alloc]
-        initWithTitle:@"About Cydia Installer"
-        buttons:[NSArray arrayWithObjects:@"Close", nil]
-        defaultButtonIndex:0
-        delegate:self
-        context:@"about"
-    ] autorelease];
-
-    [sheet setBodyText:
-        @"Copyright (C) 2008\n"
-        "Jay Freeman (saurik)\n"
-        "saurik@saurik.com\n"
-        "http://www.saurik.com/\n"
-        "\n"
-        "The Okori Group\n"
-        "http://www.theokorigroup.com/\n"
-        "\n"
-        "College of Creative Studies,\n"
-        "University of California,\n"
-        "Santa Barbara\n"
-        "http://www.ccs.ucsb.edu/"
-    ];
-
-    [sheet popupAlertAnimated:YES];
-}
-
 - (void) _rightButtonClicked {
     reloading_ = true;
     [self reloadURL];
 }
 
-- (NSString *) leftButtonTitle {
-    return @"About";
-}
-
 - (NSString *) rightButtonTitle {
     return loading_ ? @"" : @"Reload";
 }
@@ -3960,254 +4677,25 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     pushed_ = pushed;
 }
 
-@end
-/* }}} */
-
-@interface CYBook : RVBook <
-    ProgressDelegate
-> {
-    _transient Database *database_;
-    UIView *overlay_;
-    UIProgressIndicator *indicator_;
-    UITextLabel *prompt_;
-    UIProgressBar *progress_;
-    bool updating_;
-}
-
-- (id) initWithFrame:(CGRect)frame database:(Database *)database;
-- (void) update;
-- (BOOL) updating;
-
-@end
-
-/* Source Cell {{{ */
-@interface SourceCell : UITableCell {
-    UITextLabel *description_;
-    UIRightTextLabel *label_;
-    UITextLabel *origin_;
-}
-
-- (void) dealloc;
-
-- (SourceCell *) initWithSource:(Source *)source;
-
-- (void) _setSelected:(float)fraction;
-- (void) setSelected:(BOOL)selected;
-- (void) setSelected:(BOOL)selected withFade:(BOOL)fade;
-- (void) _setSelectionFadeFraction:(float)fraction;
-
-@end
-
-@implementation SourceCell
-
-- (void) dealloc {
-    [description_ release];
-    [label_ release];
-    [origin_ release];
-    [super dealloc];
-}
-
-- (SourceCell *) initWithSource:(Source *)source {
-    if ((self = [super init]) != nil) {
-        GSFontRef bold = GSFontCreateWithName("Helvetica", kGSFontTraitBold, 20);
-        GSFontRef small = GSFontCreateWithName("Helvetica", kGSFontTraitNone, 14);
-
-        CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
-        float clear[] = {0, 0, 0, 0};
-
-        NSString *description = [source description];
-        if (description == nil)
-            description = [source uri];
-
-        description_ = [[UITextLabel alloc] initWithFrame:CGRectMake(12, 7, 270, 25)];
-        [description_ setBackgroundColor:CGColorCreate(space, clear)];
-        [description_ setFont:bold];
-        [description_ setText:description];
-
-        NSString *label = [source label];
-        if (label == nil)
-            label = [source type];
-
-        label_ = [[UIRightTextLabel alloc] initWithFrame:CGRectMake(290, 32, 90, 25)];
-        [label_ setBackgroundColor:CGColorCreate(space, clear)];
-        [label_ setFont:small];
-        [label_ setText:label];
-
-        NSString *origin = [source origin];
-        if (origin == nil)
-            origin = [source distribution];
-
-        origin_ = [[UITextLabel alloc] initWithFrame:CGRectMake(13, 35, 315, 20)];
-        [origin_ setBackgroundColor:CGColorCreate(space, clear)];
-        [origin_ setFont:small];
-        [origin_ setText:origin];
-
-        [self addSubview:description_];
-        [self addSubview:label_];
-        [self addSubview:origin_];
-
-        CFRelease(small);
-        CFRelease(bold);
-    } return self;
-}
-
-- (void) _setSelected:(float)fraction {
-    CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
-
-    float black[] = {
-        Interpolate(0.0, 1.0, fraction),
-        Interpolate(0.0, 1.0, fraction),
-        Interpolate(0.0, 1.0, fraction),
-    1.0};
-
-    float blue[] = {
-        Interpolate(0.2, 1.0, fraction),
-        Interpolate(0.2, 1.0, fraction),
-        Interpolate(1.0, 1.0, fraction),
-    1.0};
-
-    float gray[] = {
-        Interpolate(0.4, 1.0, fraction),
-        Interpolate(0.4, 1.0, fraction),
-        Interpolate(0.4, 1.0, fraction),
-    1.0};
-
-    [description_ setColor:CGColorCreate(space, black)];
-    [label_ setColor:CGColorCreate(space, blue)];
-    [origin_ setColor:CGColorCreate(space, gray)];
-}
-
-- (void) setSelected:(BOOL)selected {
-    [self _setSelected:(selected ? 1.0 : 0.0)];
-    [super setSelected:selected];
-}
-
-- (void) setSelected:(BOOL)selected withFade:(BOOL)fade {
-    if (!fade)
-        [self _setSelected:(selected ? 1.0 : 0.0)];
-    [super setSelected:selected withFade:fade];
-}
-
-- (void) _setSelectionFadeFraction:(float)fraction {
-    [self _setSelected:fraction];
-    [super _setSelectionFadeFraction:fraction];
-}
-
-@end
-/* }}} */
-/* Source Table {{{ */
-@interface SourceTable : RVPage {
-    _transient Database *database_;
-    UISectionList *list_;
-    NSMutableArray *sources_;
-    UIAlertSheet *alert_;
-}
-
-- (id) initWithBook:(RVBook *)book database:(Database *)database;
-
-@end
-
-@implementation SourceTable
-
-- (void) dealloc {
-    [list_ setDataSource:nil];
-
-    if (sources_ != nil)
-        [sources_ release];
-    [list_ release];
-    [super dealloc];
-}
-
-- (int) numberOfSectionsInSectionList:(UISectionList *)list {
-    return 1;
-}
-
-- (NSString *) sectionList:(UISectionList *)list titleForSection:(int)section {
-    return @"Sources";
-}
-
-- (int) sectionList:(UISectionList *)list rowForSection:(int)section {
-    return 0;
-}
-
-- (int) numberOfRowsInTable:(UITable *)table {
-    return [sources_ count];
-}
-
-- (float) table:(UITable *)table heightForRow:(int)row {
-    return 64;
-}
-
-- (UITableCell *) table:(UITable *)table cellForRow:(int)row column:(UITableColumn *)col {
-    return [[[SourceCell alloc] initWithSource:[sources_ objectAtIndex:row]] autorelease];
-}
-
-- (BOOL) table:(UITable *)table showDisclosureForRow:(int)row {
-    return NO;
-}
-
-- (void) tableRowSelected:(NSNotification*)notification {
-    UITable *table([list_ table]);
-    int row([table selectedRow]);
-    if (row == INT_MAX)
-        return;
-
-    [table selectRow:-1 byExtendingSelection:NO withFade:YES];
-}
-
-- (id) initWithBook:(RVBook *)book database:(Database *)database {
-    if ((self = [super initWithBook:book]) != nil) {
-        database_ = database;
-        sources_ = nil;
-
-        list_ = [[UISectionList alloc] initWithFrame:[self bounds]];
-
-        [self addSubview:list_];
-
-        [list_ setDataSource:self];
-        [list_ setShouldHideHeaderInShortLists:NO];
-
-        UITableColumn *column = [[UITableColumn alloc]
-            initWithTitle:@"Name"
-            identifier:@"name"
-            width:[self frame].size.width
-        ];
-
-        UITable *table = [list_ table];
-        [table setSeparatorStyle:1];
-        [table addTableColumn:column];
-        [table setDelegate:self];
-    } return self;
-}
-
-- (void) reloadData {
-    pkgSourceList list;
-    _assert(list.ReadMainList());
-
-    if (sources_ != nil)
-        [sources_ release];
-
-    sources_ = [[NSMutableArray arrayWithCapacity:16] retain];
-    for (pkgSourceList::const_iterator source = list.begin(); source != list.end(); ++source)
-        [sources_ addObject:[[[Source alloc] initWithMetaIndex:*source] autorelease]];
-
-    [list_ reloadData];
-}
-
-- (void) resetViewAnimated:(BOOL)animated {
-    [list_ resetViewAnimated:animated];
-}
+@end
+/* }}} */
 
-- (NSString *) leftTitle {
-    return @"Refresh All";
+@interface CYBook : RVBook <
+    ProgressDelegate
+> {
+    _transient Database *database_;
+    UIView *overlay_;
+    UIProgressIndicator *indicator_;
+    UITextLabel *prompt_;
+    UIProgressBar *progress_;
+    bool updating_;
 }
 
-- (NSString *) rightTitle {
-    return @"Edit";
-}
+- (id) initWithFrame:(CGRect)frame database:(Database *)database;
+- (void) update;
+- (BOOL) updating;
 
 @end
-/* }}} */
 
 /* Install View {{{ */
 @interface InstallView : RVPage {
@@ -4295,7 +4783,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
         initWithBook:book_
         database:database_
         title:title
-        filter:@selector(isUninstalledInSection:)
+        filter:@selector(isVisiblyUninstalledInSection:)
         with:name
     ] autorelease];
 
@@ -4612,72 +5100,6 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     return @"Changes";
 }
 
-@end
-/* }}} */
-/* Manage View {{{ */
-@interface ManageView : RVPage {
-    _transient Database *database_;
-    PackageTable *packages_;
-    SourceTable *sources_;
-}
-
-- (id) initWithBook:(RVBook *)book database:(Database *)database;
-
-@end
-
-@implementation ManageView
-
-- (void) dealloc {
-    [packages_ release];
-    [sources_ release];
-    [super dealloc];
-}
-
-- (id) initWithBook:(RVBook *)book database:(Database *)database {
-    if ((self = [super initWithBook:book]) != nil) {
-        database_ = database;
-
-        packages_ = [[PackageTable alloc]
-            initWithBook:book
-            database:database
-            title:nil
-            filter:@selector(isInstalledInSection:)
-            with:nil
-        ];
-
-        sources_ = [[SourceTable alloc]
-            initWithBook:book
-            database:database
-        ];
-
-        [self addSubview:packages_];
-    } return self;
-}
-
-- (void) resetViewAnimated:(BOOL)animated {
-    [packages_ resetViewAnimated:animated];
-    [sources_ resetViewAnimated:animated];
-}
-
-- (void) reloadData {
-    [packages_ reloadData];
-    [sources_ reloadData];
-}
-
-- (NSString *) title {
-    return @"Installed Packages";
-}
-
-- (NSString *) backButtonTitle {
-    return @"Packages";
-}
-
-- (void) setDelegate:(id)delegate {
-    [super setDelegate:delegate];
-    [packages_ setDelegate:delegate];
-    [sources_ setDelegate:delegate];
-}
-
 @end
 /* }}} */
 /* Search View {{{ */
@@ -4833,7 +5255,7 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
             initWithBook:book
             database:database
             title:nil
-            filter:@selector(isSearchedForBy:)
+            filter:@selector(isVisiblySearchedForBy:)
             with:nil
         ];
 
@@ -5183,16 +5605,6 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
 
     [database_ reloadData];
 
-    if (Packages_ == nil) {
-        Packages_ = [[NSMutableDictionary alloc] initWithCapacity:128];
-        [Metadata_ setObject:Packages_ forKey:@"Packages"];
-    }
-
-    if (Sections_ == nil) {
-        Sections_ = [[NSMutableDictionary alloc] initWithCapacity:32];
-        [Metadata_ setObject:Sections_ forKey:@"Sections"];
-    }
-
     size_t changes(0);
 
     [essential_ removeAllObjects];
@@ -5237,25 +5649,60 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     [hud removeFromSuperview];*/
 }
 
-- (void) updateData {
+- (void) _saveConfig {
     if (Changed_) {
         _assert([Metadata_ writeToFile:@"/var/lib/cydia/metadata.plist" atomically:YES] == YES);
         Changed_ = false;
     }
+}
+
+- (void) updateData {
+    [self _saveConfig];
 
     /* XXX: this is just stupid */
     if (tag_ != 2)
         [install_ reloadData];
     if (tag_ != 3)
         [changes_ reloadData];
-    if (tag_ != 4)
-        [manage_ reloadData];
     if (tag_ != 5)
         [search_ reloadData];
 
     [book_ reloadData];
 }
 
+- (void) update_ {
+    [database_ update];
+}
+
+- (void) syncData {
+    FILE *file = fopen("/etc/apt/sources.list.d/cydia.list", "w");
+    _assert(file != NULL);
+
+    NSArray *keys = [Sources_ allKeys];
+
+    for (int i(0), e([keys count]); i != e; ++i) {
+        NSString *key = [keys objectAtIndex:i];
+        NSDictionary *source = [Sources_ objectForKey:key];
+
+        fprintf(file, "%s %s %s\n",
+            [[source objectForKey:@"Type"] UTF8String],
+            [[source objectForKey:@"URI"] UTF8String],
+            [[source objectForKey:@"Distribution"] UTF8String]
+        );
+    }
+
+    fclose(file);
+
+    [self _saveConfig];
+
+    [progress_
+        detachNewThreadSelector:@selector(update_)
+        toTarget:self
+        withObject:nil
+        title:@"Updating Sources..."
+    ];
+}
+
 - (void) reloadData {
     @synchronized (self) {
         if (confirm_ == nil)
@@ -5373,74 +5820,22 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     }
 }
 
-- (void) alertSheet:(UIAlertSheet *)sheet buttonClicked:(int)button {
-    NSString *context = [sheet context];
-    if ([context isEqualToString:@"fixhalf"])
-        switch (button) {
-            case 1:
-                @synchronized (self) {
-                    for (int i = 0, e = [broken_ count]; i != e; ++i) {
-                        Package *broken = [broken_ objectAtIndex:i];
-                        [broken remove];
-
-                        NSString *id = [broken id];
-                        unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.prerm", id] UTF8String]);
-                        unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.postrm", id] UTF8String]);
-                        unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.preinst", id] UTF8String]);
-                        unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.postinst", id] UTF8String]);
-                    }
-
-                    [self resolve];
-                    [self perform];
-                }
-            break;
-
-            case 2:
-                [broken_ removeAllObjects];
-                [self _loaded];
-            break;
-
-            default:
-                _assert(false);
-        }
-    else if ([context isEqualToString:@"upgrade"])
-        switch (button) {
-            case 1:
-                @synchronized (self) {
-                    for (int i = 0, e = [essential_ count]; i != e; ++i) {
-                        Package *essential = [essential_ objectAtIndex:i];
-                        [essential install];
-                    }
-
-                    [self resolve];
-                    [self perform];
-                }
-            break;
-
-            case 2:
-                Ignored_ = YES;
-            break;
-
-            default:
-                _assert(false);
-        }
-
-    [sheet dismiss];
-}
-
 - (void) setPage:(RVPage *)page {
     [page resetViewAnimated:NO];
     [page setDelegate:self];
     [book_ setPage:page];
 }
 
-- (RVPage *) _setHomePage {
-    BrowserView *browser = [[[BrowserView alloc] initWithBook:book_ database:database_] autorelease];
-    [self setPage:browser];
-    [browser loadURL:[NSURL URLWithString:@"http://cydia.saurik.com/"]];
+- (RVPage *) _pageForURL:(NSURL *)url withClass:(Class)_class {
+    BrowserView *browser = [[[_class alloc] initWithBook:book_ database:database_] autorelease];
+    [browser loadURL:url];
     return browser;
 }
 
+- (void) _setHomePage {
+    [self setPage:[self _pageForURL:[NSURL URLWithString:@"http://cydia.saurik.com/"] withClass:[HomeView class]]];
+}
+
 - (void) buttonBarItemTapped:(id)sender {
     unsigned tag = [sender tag];
     if (tag == tag_) {
@@ -5494,6 +5889,23 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     [super applicationWillSuspend];
 }
 
+- (void) askForSettings {
+    UIAlertSheet *role = [[[UIAlertSheet alloc]
+        initWithTitle:@"Who Are You?"
+        buttons:[NSArray arrayWithObjects:
+            @"User (Graphical Only)",
+            @"Hacker (Command Line)",
+            @"Developer (No Filters)",
+        nil]
+        defaultButtonIndex:-1
+        delegate:self
+        context:@"role"
+    ] autorelease];
+
+    [role setBodyText:@"Not all of the packages available via Cydia are designed to be used by all users. Please categorize yourself so that Cydia can apply helpful filters.\n\nThis choice can be changed from \"Settings\" under the \"Manage\" tab."];
+    [role popupAlertAnimated:YES];
+}
+
 - (void) finish {
     if (hud_ != nil) {
         [self setStatusBarShowsProgress:NO];
@@ -5512,6 +5924,11 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
         return;
     }
 
+    if (Role_ == nil) {
+        [self askForSettings];
+        return;
+    }
+
     overlay_ = [[UIView alloc] initWithFrame:[underlay_ bounds]];
 
     CGRect screenrect = [UIHardware fullScreenApplicationContentRect];
@@ -5609,9 +6026,13 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
 
     install_ = [[InstallView alloc] initWithBook:book_ database:database_];
     changes_ = [[ChangesView alloc] initWithBook:book_ database:database_];
-    manage_ = [[ManageView alloc] initWithBook:book_ database:database_];
     search_ = [[SearchView alloc] initWithBook:book_ database:database_];
 
+    manage_ = (ManageView *) [[self
+        _pageForURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"manage" ofType:@"html"]]
+        withClass:[ManageView class]
+    ] retain];
+
     if (!bootstrap_)
         [underlay_ addSubview:overlay_];
 
@@ -5623,6 +6044,86 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
         [self _setHomePage];
 }
 
+- (void) alertSheet:(UIAlertSheet *)sheet buttonClicked:(int)button {
+    NSString *context = [sheet context];
+    if ([context isEqualToString:@"fixhalf"])
+        switch (button) {
+            case 1:
+                @synchronized (self) {
+                    for (int i = 0, e = [broken_ count]; i != e; ++i) {
+                        Package *broken = [broken_ objectAtIndex:i];
+                        [broken remove];
+
+                        NSString *id = [broken id];
+                        unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.prerm", id] UTF8String]);
+                        unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.postrm", id] UTF8String]);
+                        unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.preinst", id] UTF8String]);
+                        unlink([[NSString stringWithFormat:@"/var/lib/dpkg/info/%@.postinst", id] UTF8String]);
+                    }
+
+                    [self resolve];
+                    [self perform];
+                }
+            break;
+
+            case 2:
+                [broken_ removeAllObjects];
+                [self _loaded];
+            break;
+
+            default:
+                _assert(false);
+        }
+    else if ([context isEqualToString:@"role"]) {
+        switch (button) {
+            case 1: Role_ = @"User"; break;
+            case 2: Role_ = @"Hacker"; break;
+            case 3: Role_ = @"Developer"; break;
+
+            default:
+                Role_ = nil;
+                _assert(false);
+        }
+
+        bool reset = Settings_ != nil;
+
+        Settings_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+            Role_, @"Role",
+        nil];
+
+        [Metadata_ setObject:Settings_ forKey:@"Settings"];
+
+        Changed_ = true;
+
+        if (reset)
+            [self updateData];
+        else
+            [self finish];
+    } else if ([context isEqualToString:@"upgrade"])
+        switch (button) {
+            case 1:
+                @synchronized (self) {
+                    for (int i = 0, e = [essential_ count]; i != e; ++i) {
+                        Package *essential = [essential_ objectAtIndex:i];
+                        [essential install];
+                    }
+
+                    [self resolve];
+                    [self perform];
+                }
+            break;
+
+            case 2:
+                Ignored_ = YES;
+            break;
+
+            default:
+                _assert(false);
+        }
+
+    [sheet dismiss];
+}
+
 - (void) reorganize {
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     system("/usr/libexec/cydia/free.sh");
@@ -5645,6 +6146,13 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
         [super _setSuspended:value];
 }
 
+- (UIProgressHUD *) addProgressHUD {
+    UIProgressHUD *hud = [[UIProgressHUD alloc] initWithWindow:window_];
+    [hud show:YES];
+    [underlay_ addSubview:hud];
+    return hud;
+}
+
 - (void) applicationDidFinishLaunching:(id)unused {
     _assert(pkgInitConfig(*_config));
     _assert(pkgInitSystem(*_config, _system));
@@ -5682,10 +6190,8 @@ Pcre conffile_r("^'(.*)' '(.*)' ([01]) ([01])$");
     ) {
         [self setIdleTimerDisabled:YES];
 
-        hud_ = [[UIProgressHUD alloc] initWithWindow:window_];
+        hud_ = [self addProgressHUD];
         [hud_ setText:@"Reorganizing\n\nWill Automatically\nRestart When Done"];
-        [hud_ show:YES];
-        [underlay_ addSubview:hud_];
 
         [self setStatusBarShowsProgress:YES];
 
@@ -5851,8 +6357,29 @@ int main(int argc, char *argv[]) {
     if ((Metadata_ = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/lib/cydia/metadata.plist"]) == NULL)
         Metadata_ = [[NSMutableDictionary alloc] initWithCapacity:2];
     else {
+        Settings_ = [Metadata_ objectForKey:@"Settings"];
+
         Packages_ = [Metadata_ objectForKey:@"Packages"];
         Sections_ = [Metadata_ objectForKey:@"Sections"];
+        Sources_ = [Metadata_ objectForKey:@"Sources"];
+    }
+
+    if (Settings_ != nil)
+        Role_ = [Settings_ objectForKey:@"Role"];
+
+    if (Packages_ == nil) {
+        Packages_ = [[[NSMutableDictionary alloc] initWithCapacity:128] autorelease];
+        [Metadata_ setObject:Packages_ forKey:@"Packages"];
+    }
+
+    if (Sections_ == nil) {
+        Sections_ = [[[NSMutableDictionary alloc] initWithCapacity:32] autorelease];
+        [Metadata_ setObject:Sections_ forKey:@"Sections"];
+    }
+
+    if (Sources_ == nil) {
+        Sources_ = [[[NSMutableDictionary alloc] initWithCapacity:0] autorelease];
+        [Metadata_ setObject:Sources_ forKey:@"Sources"];
     }
 
     if (access("/User", F_OK) != 0)
@@ -5866,6 +6393,22 @@ int main(int argc, char *argv[]) {
     Clear_.Set(space_, 0.0, 0.0, 0.0, 0.0);
     Red_.Set(space_, 1.0, 0.0, 0.0, 1.0);
     White_.Set(space_, 1.0, 1.0, 1.0, 1.0);
+    Gray_.Set(space_, 0.4, 0.4, 0.4, 1.0);
+
+    SectionMap_ = [NSMutableDictionary dictionaryWithCapacity:16]; {
+        std::ifstream fin([[[NSBundle mainBundle] pathForResource:@"sections" ofType:@"txt"] UTF8String]);
+        std::string line;
+        while (std::getline(fin, line)) {
+            size_t space = line.find_first_of(' ');
+            if (space == std::string::npos)
+                continue;
+            [SectionMap_
+                setObject:[NSString stringWithUTF8String:line.substr(space + 1).c_str()]
+                forKey:[NSString stringWithUTF8String:line.substr(0, space).c_str()]
+            ];
+        }
+    }
+
 
     int value = UIApplicationMain(argc, argv, [Cydia class]);
 
index ccd3e426b0235d0ba9875a4c37675c36dc21f2ae..d83d7608051339e163aa3eb911f5ecfec43ee887 100644 (file)
 - (void) reloadButtonsForPage:(RVPage *)page {
     if ([pages_ count] == 0 || page != [pages_ lastObject])
         return;
-    NSString *leftButtonTitle([pages_ count] == 1 ? [page leftButtonTitle] : nil);
-    [navbar_ showButtonsWithLeftTitle:leftButtonTitle rightTitle:[page rightButtonTitle]];
+    NSString *leftButtonTitle([page leftButtonTitle]);
+    RVUINavBarButtonStyle leftButtonStyle = [page leftButtonStyle];
+    RVUINavBarButtonStyle rightButtonStyle = [page rightButtonStyle];
+    //[navbar_ showButtonsWithLeftTitle:leftButtonTitle rightTitle:[page rightButtonTitle] leftBack:(leftButtonTitle == nil)];
+
+    [navbar_
+        showLeftButton:leftButtonTitle
+        withStyle:leftButtonStyle
+        rightButton:[page rightButtonTitle]
+        withStyle:rightButtonStyle
+    ];
 }
 
 - (NSString *) getTitleForPage:(RVPage *)page {
index 5065dd2dcc67b2fc3bd0b356cb8be4ee0d721068..8b0a2e41619e0478a88406bc471fbbb330a44840 100644 (file)
@@ -2,6 +2,13 @@
 
 #import <UIKit/UIView.h>
 
+enum RVUINavBarButtonStyle {
+    RVUINavBarButtonStyleNormal,
+    RVUINavBarButtonStyleBack,
+    RVUINavBarButtonStyleHighlighted,
+    RVUINavBarButtonStyleDestructive
+};
+
 @class NSString;
 @class RVBook;
 
@@ -16,6 +23,9 @@
 - (NSString *) leftButtonTitle;
 - (UIView *) accessoryView;
 
+- (RVUINavBarButtonStyle) leftButtonStyle;
+- (RVUINavBarButtonStyle) rightButtonStyle;
+
 - (void) _rightButtonClicked;
 - (void) _leftButtonClicked;
 
index a92058ecde59107f41cb160227dbc1a364de4ecf..ee85a7ed6c4b6ca7d7a7f521b4dfbed6e93a3112 100644 (file)
     return nil;
 }
 
+- (RVUINavBarButtonStyle) leftButtonStyle {
+    return [self leftButtonTitle] == nil ? RVUINavBarButtonStyleBack : RVUINavBarButtonStyleNormal;
+}
+
+- (RVUINavBarButtonStyle) rightButtonStyle {
+    return RVUINavBarButtonStyleNormal;
+}
+
 - (void) _rightButtonClicked {
     [self doesNotRecognizeSelector:_cmd];
 }
index ee8fa99f3a8f295ad4d93ab7e0bb59e4680c1231..3a58e58358dedd5d9ff7031cbb7dffe5868e4051 100644 (file)
--- a/makefile
+++ b/makefile
@@ -19,7 +19,7 @@ exec: exec.mm makefile
        $(target)g++ -Wall -Werror -o $@ $< -framework Foundation -framework CoreFoundation -lobjc
 
 Cydia: Cydia.mm ../uicaboodle.m/*.mm *.h makefile
-       $(target)g++ -I../uicaboodle.m -fobjc-call-cxx-cdtors -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework IOKit -framework CoreFoundation -framework Foundation -framework CoreGraphics -framework GraphicsServices $(frameworks) -lobjc -lapt-pkg -lpcre -fobjc-exceptions -I/apl/i20 -F"$${PKG_ROOT}"/System/Library/PrivateFrameworks
+       $(target)g++ -march=armv6 -mcpu=arm1176jzf-s -I../uicaboodle.m -fobjc-call-cxx-cdtors -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework IOKit -framework CoreFoundation -framework Foundation -framework CoreGraphics -framework GraphicsServices $(frameworks) -lobjc -lapt-pkg -lpcre -fobjc-exceptions -I/apl/i20 -F"$${PKG_ROOT}"/System/Library/PrivateFrameworks
 
 sign: Cydia
        CODESIGN_ALLOCATE=$$(which "$(target)codesign_allocate") /apl/tel/util/ldid -S Cydia