summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--CyteKit/PerlCompatibleRegEx.hpp24
-rwxr-xr-xLibrary/firmware.sh4
-rw-r--r--MobileCydia.mm43
-rw-r--r--Sources.mm7
-rw-r--r--cfversion.mm7
-rw-r--r--makefile7
7 files changed, 66 insertions, 27 deletions
diff --git a/.gitignore b/.gitignore
index 5b341bd..855b1e8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ debs
*.o
Images/
Version.h
+cfversion
diff --git a/CyteKit/PerlCompatibleRegEx.hpp b/CyteKit/PerlCompatibleRegEx.hpp
index e1c0e2e..38a9462 100644
--- a/CyteKit/PerlCompatibleRegEx.hpp
+++ b/CyteKit/PerlCompatibleRegEx.hpp
@@ -56,15 +56,20 @@ class Pcre {
public:
Pcre() :
code_(NULL),
- study_(NULL)
+ study_(NULL),
+ data_(NULL)
{
}
- Pcre(const char *regex) :
+ Pcre(const char *regex, NSString *data = nil) :
code_(NULL),
- study_(NULL)
+ study_(NULL),
+ data_(NULL)
{
this->operator =(regex);
+
+ if (data != nil)
+ this->operator ()(data);
}
void operator =(const char *regex) {
@@ -102,8 +107,17 @@ class Pcre {
}
bool operator ()(const char *data, size_t size) {
- data_ = data;
- return pcre_exec(code_, study_, data, size, 0, 0, matches_, (capture_ + 1) * 3) >= 0;
+ if (pcre_exec(code_, study_, data, size, 0, 0, matches_, (capture_ + 1) * 3) >= 0) {
+ data_ = data;
+ return true;
+ } else {
+ data_ = NULL;
+ return false;
+ }
+ }
+
+ operator bool() const {
+ return data_ != NULL;
}
NSString *operator ->*(NSString *format) const {
diff --git a/Library/firmware.sh b/Library/firmware.sh
index 4f41bfd..ac1381d 100755
--- a/Library/firmware.sh
+++ b/Library/firmware.sh
@@ -130,6 +130,8 @@ EOF
pseudo "cy+kernel.$(lower <<<$(sysctl -n kern.ostype))" "$(sysctl -n kern.osrelease)" "virtual kernel dependency"
+ pseudo "cy+lib.corefoundation" "$(/usr/libexec/cydia/cfversion)" "virtual corefoundation dependency"
+
} >"${status}"_
mv -f "${status}"{_,}
@@ -139,5 +141,5 @@ if [[ ${cpu} == arm ]]; then
cp -afT /User /var/mobile
fi && rm -rf /User && ln -s "/var/mobile" /User
- echo 4 >/var/lib/cydia/firmware.ver
+ echo 5 >/var/lib/cydia/firmware.ver
fi
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 0352e89..2b16ee2 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -685,14 +685,15 @@ static _H<UIFont> Font18Bold_;
static _H<UIFont> Font22Bold_;
static const char *Machine_ = NULL;
-_H<NSString> System_;
+static _H<NSString> System_;
static NSString *SerialNumber_ = nil;
static NSString *ChipID_ = nil;
static NSString *BBSNum_ = nil;
static _H<NSString> Token_;
static NSString *UniqueID_ = nil;
-static NSString *Product_ = nil;
-static NSString *Safari_ = nil;
+static _H<NSString> UserAgent_;
+static _H<NSString> Product_;
+static _H<NSString> Safari_;
static CFLocaleRef Locale_;
static NSArray *Languages_;
@@ -3953,6 +3954,8 @@ static _H<NSMutableSet> Diversions_;
+ (NSArray *) _attributeKeys {
return [NSArray arrayWithObjects:
@"bbsnum",
+ @"build",
+ @"coreFoundationVersionNumber",
@"device",
@"ecid",
@"firmware",
@@ -3981,6 +3984,14 @@ static _H<NSMutableSet> Diversions_;
return Cydia_;
}
+- (NSString *) build {
+ return System_;
+}
+
+- (NSString *) coreFoundationVersionNumber {
+ return [NSString stringWithFormat:@"%.2f", kCFCoreFoundationVersionNumber];
+}
+
- (NSString *) device {
return [[UIDevice currentDevice] uniqueIdentifier];
}
@@ -4563,6 +4574,8 @@ static _H<NSMutableSet> Diversions_;
NSMutableURLRequest *copy([[super webView:view resource:resource willSendRequest:request redirectResponse:response fromDataSource:source] mutableCopy]);
+ if ([copy valueForHTTPHeaderField:@"X-Cydia-Cf-Version"] == nil)
+ [copy setValue:[NSString stringWithFormat:@"%.2f", kCFCoreFoundationVersionNumber] forHTTPHeaderField:@"X-Cydia-Cf-Version"];
if (Machine_ != NULL && [copy valueForHTTPHeaderField:@"X-Machine"] == nil)
[copy setValue:[NSString stringWithUTF8String:Machine_] forHTTPHeaderField:@"X-Machine"];
@@ -4593,16 +4606,7 @@ static _H<NSMutableSet> Diversions_;
}
- (NSString *) applicationNameForUserAgent {
- NSString *application([NSString stringWithFormat:@"Cydia/%@", Cydia_]);
-
- if (Safari_ != nil)
- application = [NSString stringWithFormat:@"Safari/%@ %@", Safari_, application];
- if (System_ != nil)
- application = [NSString stringWithFormat:@"Mobile/%@ %@", (id) System_, application];
- if (Product_ != nil)
- application = [NSString stringWithFormat:@"Version/%@ %@", Product_, application];
-
- return application;
+ return UserAgent_;
}
- (id) init {
@@ -10218,6 +10222,17 @@ int main(int argc, char *argv[]) {
Product_ = [info objectForKey:@"SafariProductVersion"];
Safari_ = [info objectForKey:@"CFBundleVersion"];
}
+
+ NSString *agent([NSString stringWithFormat:@"Cydia/%@ CF/%.2f", Cydia_, kCFCoreFoundationVersionNumber]);
+
+ if (Pcre match = Pcre("^[0-9]+(\\.[0-9]+)+", Safari_))
+ agent = [NSString stringWithFormat:@"Safari/%@ %@", match[0], agent];
+ if (Pcre match = Pcre("^[0-9]+[A-Z][0-9]+[a-z]?", System_))
+ agent = [NSString stringWithFormat:@"Mobile/%@ %@", match[0], agent];
+ if (Pcre match = Pcre("^[0-9]+(\\.[0-9]+)+", Product_))
+ agent = [NSString stringWithFormat:@"Version/%@ %@", match[0], agent];
+
+ UserAgent_ = agent;
/* }}} */
/* Load Database {{{ */
_trace();
@@ -10319,7 +10334,7 @@ int main(int argc, char *argv[]) {
if (access("/tmp/.cydia.fw", F_OK) == 0) {
unlink("/tmp/.cydia.fw");
goto firmware;
- } else if (access("/User", F_OK) != 0 || version < 4) {
+ } else if (access("/User", F_OK) != 0 || version < 5) {
firmware:
_trace();
system("/usr/libexec/cydia/firmware.sh");
diff --git a/Sources.mm b/Sources.mm
index 6073622..15528b7 100644
--- a/Sources.mm
+++ b/Sources.mm
@@ -44,18 +44,13 @@
#include <cstdio>
extern _H<NSMutableDictionary> Sources_;
-extern _H<NSString> System_;
extern bool Changed_;
void CydiaWriteSources() {
FILE *file(fopen("/etc/apt/sources.list.d/cydia.list", "w"));
_assert(file != NULL);
- NSString *distribution(@"ios");
- if (System_ != nil)
- distribution = [distribution stringByAppendingString:[NSString stringWithFormat:@"/%@", (id) System_]];
-
- fprintf(file, "deb http://apt.saurik.com/ %s main\n", [distribution UTF8String]);
+ fprintf(file, "deb http://apt.saurik.com/ ios/%.2f main\n", kCFCoreFoundationVersionNumber);
for (NSString *key in [Sources_ allKeys]) {
NSDictionary *source([Sources_ objectForKey:key]);
diff --git a/cfversion.mm b/cfversion.mm
new file mode 100644
index 0000000..6be6c71
--- /dev/null
+++ b/cfversion.mm
@@ -0,0 +1,7 @@
+#include <CoreFoundation/CoreFoundation.h>
+#include <cstdio>
+
+int main() {
+ printf("%.2f\n", kCFCoreFoundationVersionNumber);
+ return 0;
+}
diff --git a/makefile b/makefile
index f1ebe56..5c5690f 100644
--- a/makefile
+++ b/makefile
@@ -130,11 +130,15 @@ MobileCydia: sysroot $(object)
CydiaAppliance: CydiaAppliance.mm
$(cycc) $(filter %.mm,$^) $(flags) -bundle $(link) $(backrow)
+cfversion: cfversion.mm
+ $(cycc) $(filter %.mm,$^) $(flags) -framework CoreFoundation
+ @ldid -T0 -S $@
+
postinst: postinst.mm Sources.mm Sources.h CyteKit/stringWithUTF8Bytes.mm CyteKit/stringWithUTF8Bytes.h CyteKit/UCPlatform.h
$(cycc) $(filter %.mm,$^) $(flags) -framework CoreFoundation -framework Foundation -framework UIKit -lpcre
@ldid -T0 -S $@
-debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst postinst $(images) $(shell find MobileCydia.app) cydia.control
+debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst postinst cfversion $(images) $(shell find MobileCydia.app) cydia.control Library/firmware.sh
sudo rm -rf _
mkdir -p _/var/lib/cydia
@@ -145,6 +149,7 @@ debs/cydia_$(version)_iphoneos-arm.deb: MobileCydia preinst postinst $(images) $
mkdir -p _/usr/libexec
cp -a Library _/usr/libexec/cydia
cp -a sysroot/usr/bin/du _/usr/libexec/cydia
+ cp -a cfversion _/usr/libexec/cydia
mkdir -p _/System/Library
cp -a LaunchDaemons _/System/Library/LaunchDaemons