#include <QuartzCore/CALayer.h>
#include <WebCore/WebCoreThread.h>
-#include <WebKit/DOMHTMLIFrameElement.h>
#include <algorithm>
+#include <fstream>
#include <iomanip>
#include <set>
#include <sstream>
#include <string>
-#include <ext/stdio_filebuf.h>
+#include "fdstream.hpp"
#undef ABS
+#include "apt.h"
#include <apt-pkg/acquire.h>
#include <apt-pkg/acquire-item.h>
#include <apt-pkg/algorithms.h>
CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const uint8_t *>(data), size, kCFStringEncodingISOLatin1, NO, kCFAllocatorNull);
}
+static _finline CFStringRef CYStringCreate(const std::string &data) {
+ return CYStringCreate(data.data(), data.size());
+}
+
static _finline CFStringRef CYStringCreate(const char *data) {
return CYStringCreate(data, strlen(data));
}
+ (Database *) sharedInstance;
- (unsigned) era;
+- (bool) hasPackages;
- (void) _readCydia:(NSNumber *)fd;
- (void) _readStatus:(NSNumber *)fd;
char version_[8];
char name_[];
-};
+} _packed;
struct MetaValue :
Cytore::Block
{
uint32_t active_;
Cytore::Offset<PackageValue> packages_[1 << 16];
-};
+} _packed;
static Cytore::File<MetaValue> MetaFile_;
// }}}
_end
_profile(Package$parse$Tagline)
- const char *start, *end;
- if (parser->ShortDesc(start, end)) {
- const char *stop(reinterpret_cast<const char *>(memchr(start, '\n', end - start)));
- if (stop == NULL)
- stop = end;
- while (stop != start && stop[-1] == '\r')
- --stop;
- parsed->tagline_.set(pool_, start, stop - start);
- }
+ parsed->tagline_.set(pool_, parser->ShortDesc());
_end
_profile(Package$parse$Retain)
version_ = version;
- pkgCache::PkgIterator iterator(version.ParentPkg());
+ pkgCache::PkgIterator iterator(version_.ParentPkg());
iterator_ = iterator;
_profile(Package$initWithVersion$Version)
_end
_profile(Package$initWithVersion$Cache)
- name_.set(NULL, iterator.Display());
+ name_.set(NULL, version_.Display());
latest_.set(NULL, StripVersion_(version_.VerStr()));
} while (false); _end
_profile(Package$initWithVersion$Tags)
+#ifdef __arm64__
+ pkgCache::TagIterator tag(version_.TagList());
+#else
pkgCache::TagIterator tag(iterator.TagList());
+#endif
if (!tag.end()) {
tags_ = [NSMutableArray arrayWithCapacity:8];
@synchronized (database_) {
pkgRecords::Parser &parser([database_ records]->Lookup(file_));
-
- const char *start, *end;
- if (!parser.ShortDesc(start, end))
+ std::string value(parser.ShortDesc());
+ if (value.empty())
return nil;
-
- if (end - start > 200)
- end = start + 200;
-
- /*
- if (const char *stop = reinterpret_cast<const char *>(memchr(start, '\n', end - start)))
- end = stop;
-
- while (end != start && end[-1] == '\r')
- --end;
- */
-
- return [(id) CYStringCreate(start, end - start) autorelease];
+ if (value.size() > 200)
+ value.resize(200);
+ return [(id) CYStringCreate(value) autorelease];
} }
- (unichar) index {
CFArrayRemoveAllValues(packages_);
}
+- (bool) hasPackages {
+ return CFArrayGetCount(packages_) != 0;
+}
+
- (void) dealloc {
// XXX: actually implement this thing
_assert(false);
}
- (void) _readCydia:(NSNumber *)fd {
- __gnu_cxx::stdio_filebuf<char> ib([fd intValue], std::ios::in);
- std::istream is(&ib);
+ boost::fdistream is([fd intValue]);
std::string line;
static RegEx finish_r("finish:([^:]*)");
}
- (void) _readStatus:(NSNumber *)fd {
- __gnu_cxx::stdio_filebuf<char> ib([fd intValue], std::ios::in);
- std::istream is(&ib);
+ boost::fdistream is([fd intValue]);
std::string line;
static RegEx conffile_r("status: [^ ]* : conffile-prompt : (.*?) *");
}
- (void) _readOutput:(NSNumber *)fd {
- __gnu_cxx::stdio_filebuf<char> ib([fd intValue], std::ios::in);
- std::istream is(&ib);
+ boost::fdistream is([fd intValue]);
std::string line;
while (std::getline(is, line)) {
@synchronized (self) {
if (static_cast<pkgDepCache *>(cache_) == NULL)
return nil;
- pkgCache::PkgIterator iterator(cache_->FindPkg([name UTF8String]));
+ pkgCache::PkgIterator iterator(cache_->FindPkg([name UTF8String]
+#ifdef __arm64__
+ , "any"
+#endif
+ ));
return iterator.end() ? nil : [Package packageWithIterator:iterator withZone:NULL inPool:NULL database:self];
} }
opened = cache_.Open(progress, false);
_end
if (!opened) {
- // XXX: what if there are errors, but Open() == true? this should be merged with popError:
+ // XXX: this block should probably be merged with popError: in some way
while (!_error->empty()) {
std::string error;
bool warning(!_error->PopMessage(error));
}
return;
- }
+ } else if ([self popErrorWithTitle:title forOperation:true])
+ return;
_trace();
unlink("/tmp/cydia.chk");
+ (NSArray *) _attributeKeys {
return [NSArray arrayWithObjects:
+ @"bittage",
@"bbsnum",
@"build",
@"cells",
return Cydia_;
}
+- (unsigned) bittage {
+#if 0
+#elif defined(__arm64__)
+ return 64;
+#elif defined(__arm__)
+ return 32;
+#else
+ return 0;
+#endif
+}
+
- (NSString *) build {
return System_;
}
}
- (NSArray *) getDisplayIdentifiers {
- NSSet *set([SBSCopyApplicationDisplayIdentifiers() autorelease]);
- if (set == nil || ![set isKindOfClass:[NSSet class]])
- return [NSArray array];
- return [set allObjects];
+ return SBSCopyApplicationDisplayIdentifiers(false, false);
}
- (NSString *) getLocalizedNameForDisplayIdentifier:(NSString *)identifier {
}
- (NSString *) substitutePackageNames:(NSString *)message {
+ auto database([Database sharedInstance]);
+
+ // XXX: this check is less racy than you'd expect, but this entire concept is a little awkward
+ if (![database hasPackages])
+ return message;
+
NSMutableArray *words([[[message componentsSeparatedByString:@" "] mutableCopy] autorelease]);
for (size_t i(0), e([words count]); i != e; ++i) {
NSString *word([words objectAtIndex:i]);
- if (Package *package = [[Database sharedInstance] packageWithName:word])
+ if (Package *package = [database packageWithName:word])
[words replaceObjectAtIndex:i withObject:[package name]];
}
[self setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/#!/progress/", UI_]]];
- [scroller_ setBackgroundColor:[UIColor blackColor]];
+ [self setPageColor:[UIColor blackColor]];
[[self navigationItem] setHidesBackButton:YES];
NSString *directory = [stack lastObject];
[stack addObject:[file stringByAppendingString:@"/"]];
[files_ replaceObjectAtIndex:i withObject:[NSString stringWithFormat:@"%*s%@",
- ([stack count] - 2) * 3, "",
+ int(([stack count] - 2) * 3), "",
[file substringFromIndex:[directory length]]
]];
}
[Sources_ removeObjectForKey:[source key]];
- [delegate_ _saveConfig];
- [delegate_ reloadDataWithInvocation:nil];
+ [delegate_ syncData];
}
}
[alert setNumberOfRows:1];
[alert addTextFieldWithValue:@"http://" label:@""];
- UITextInputTraits *traits = [[alert textField] textInputTraits];
+ NSObject<UITextInputTraits> *traits = [[alert textField] textInputTraits];
[traits setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[traits setAutocorrectionType:UITextAutocorrectionTypeNo];
[traits setKeyboardType:UIKeyboardTypeURL];
- (void) reloadSpringBoard {
if (kCFCoreFoundationVersionNumber >= 700) // XXX: iOS 6.x
- system("/bin/launchctl stop com.apple.backboardd");
+ system("/usr/libexec/cydia/cydo /bin/launchctl stop com.apple.backboardd");
else
- system("/bin/launchctl stop com.apple.SpringBoard");
+ system("/usr/libexec/cydia/cydo /bin/launchctl stop com.apple.SpringBoard");
sleep(15);
system("/usr/bin/killall backboardd SpringBoard");
}
[super applicationSuspend];
}
-- (void) applicationSuspend:(__GSEvent *)event {
+- (void) applicationSuspend:(GSEventRef)event {
if ([self isSafeToSuspend])
[super applicationSuspend:event];
}
return [(NSMutableDictionary *) copy autorelease];
}
+int main_store(int, char *argv[]);
+
int main(int argc, char *argv[]) {
+#ifdef __arm64__
+ const char *argv0(argv[0]);
+ if (const char *slash = strrchr(argv0, '/'))
+ argv0 = slash + 1;
+ if (false);
+ else if (!strcmp(argv0, "store"))
+ return main_store(argc, argv);
+#endif
+
int fd(open("/tmp/cydia.log", O_WRONLY | O_APPEND | O_CREAT, 0644));
dup2(fd, 2);
close(fd);
Locale_ = CFLocaleCopyCurrent();
Languages_ = [NSLocale preferredLanguages];
- //CFStringRef locale(CFLocaleGetIdentifier(Locale_));
- //NSLog(@"%@", [Languages_ description]);
+ std::string languages;
+ const char *translation(NULL);
- const char *lang;
+ // XXX: this isn't really a language, but this is compatible with older Cydia builds
if (Locale_ != NULL)
- lang = [(NSString *) CFLocaleGetIdentifier(Locale_) UTF8String];
- else if (Languages_ != nil && [Languages_ count] != 0)
- lang = [[Languages_ objectAtIndex:0] UTF8String];
- else
- // XXX: consider just setting to C and then falling through?
- lang = NULL;
-
- if (lang != NULL) {
- RegEx pattern("([a-z][a-z])(?:-[A-Za-z]*)?(_[A-Z][A-Z])?");
- lang = !pattern(lang) ? NULL : [pattern->*@"%1$@%2$@" UTF8String];
- }
+ if (const char *language = [(NSString *) CFLocaleGetIdentifier(Locale_) UTF8String]) {
+ RegEx pattern("([a-z][a-z])(?:-[A-Za-z]*)?(_[A-Z][A-Z])?");
+ if (pattern(language)) {
+ translation = strdup([pattern->*@"%1$@%2$@" UTF8String]);
+ languages += translation;
+ languages += ",";
+ }
+ }
- NSLog(@"Setting Language: %s", lang);
+ if (Languages_ != nil)
+ for (NSString *language : Languages_) {
+ languages += [language UTF8String];
+ languages += ",";
+ }
- if (lang != NULL) {
- setenv("LANG", lang, true);
- std::setlocale(LC_ALL, lang);
- }
+ languages += "en";
+ NSLog(@"Setting Language: [%s] %s", translation, languages.c_str());
/* }}} */
/* Index Collation {{{ */
if (Class $UILocalizedIndexedCollation = objc_getClass("UILocalizedIndexedCollation")) { @try {
_assert(pkgInitConfig(*_config));
_assert(pkgInitSystem(*_config, _system));
- if (lang != NULL)
- _config->Set("APT::Acquire::Translation", lang);
+ _config->Set("Acquire::AllowInsecureRepositories", true);
+ _config->Set("Acquire::Check-Valid-Until", false);
+ _config->Set("Dir::Bin::Methods::store", "/Applications/Cydia.app/store");
+
+ _config->Set("pkgCacheGen::ForceEssential", "");
+
+ if (translation != NULL)
+ _config->Set("APT::Acquire::Translation", translation);
+ _config->Set("Acquire::Languages", languages);
// XXX: this timeout might be important :(
//_config->Set("Acquire::http::Timeout", 15);
std::string logs("/var/mobile/Library/Logs/Cydia");
mkdir(logs.c_str(), 0755);
- _config->Set("Dir::Log::Terminal", logs + "/apt.log");
+ _config->Set("Dir::Log", logs);
_config->Set("Dir::Bin::dpkg", "/usr/libexec/cydia/cydo");
/* }}} */