summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2008-03-08 21:57:55 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2008-03-08 21:57:55 +0000
commitc7c6384e1b4b08d546b9f1d7728c218eee42ac0f (patch)
tree0d7f37e41222642d1d5f11367471f2d1d3160922
parentec97ef06d3da4f9426d971319fc1b8c6eaf5631a (diff)
Label width, move.sh, and Default-Icon.
-rw-r--r--Cydia.mm28
-rwxr-xr-xLibrary/move.sh59
2 files changed, 81 insertions, 6 deletions
diff --git a/Cydia.mm b/Cydia.mm
index 0fc182c..53e94b1 100644
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -937,6 +937,8 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
NSString *type_;
NSString *version_;
+ NSString *defaultIcon_;
+
BOOL trusted_;
}
@@ -954,6 +956,8 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
- (NSString *) label;
- (NSString *) origin;
- (NSString *) version;
+
+- (NSString *) defaultIcon;
@end
@implementation Source
@@ -1001,7 +1005,9 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
while (!value.empty() && value[0] == ' ')
value = value.substr(1);
- if (name == "Description")
+ if (name == "Default-Icon")
+ defaultIcon_ = [[NSString stringWithCString:value.c_str()] retain];
+ else if (name == "Description")
description_ = [[NSString stringWithCString:value.c_str()] retain];
else if (name == "Label")
label_ = [[NSString stringWithCString:value.c_str()] retain];
@@ -1046,6 +1052,10 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
return version_;
}
+- (NSString *) defaultIcon {
+ return defaultIcon_;
+}
+
@end
/* }}} */
/* Package Class {{{ */
@@ -1707,7 +1717,7 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
[description_ setBackgroundColor:clear];
[description_ setFont:small];
- source_ = [[UITextLabel alloc] initWithFrame:CGRectMake(12, 72, 150, 20)];
+ source_ = [[UITextLabel alloc] initWithFrame:CGRectMake(12, 72, 225, 20)];
[source_ setBackgroundColor:clear];
[source_ setFont:large];
@@ -1734,9 +1744,13 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
}
- (void) setPackage:(Package *)package {
+ Source *source = [package source];
+
UIImage *image = nil;
if (NSString *icon = [package icon])
image = [UIImage imageAtPath:[icon substringFromIndex:6]];
+ if (image == nil) if (NSString *icon = [source defaultIcon])
+ image = [UIImage imageAtPath:[icon substringFromIndex:6]];
if (image == nil)
image = [UIImage applicationImageNamed:@"unknown.png"];
@@ -1748,16 +1762,18 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
[version_ setText:[package latest]];
[description_ setText:[package tagline]];
- Source *source = [package source];
NSString *label;
bool trusted;
- if (source == nil) {
+ if (source != nil) {
+ label = [source label];
+ trusted = [source trusted];
+ } else if ([[package id] isEqualToString:@"firmware"]) {
label = @"Apple";
trusted = false;
} else {
- label = [source label];
- trusted = [source trusted];
+ label = @"Unknown/Local";
+ trusted = false;
}
[source_ setText:[NSString stringWithFormat:@"from %@", label]];
diff --git a/Library/move.sh b/Library/move.sh
new file mode 100755
index 0000000..31c89e4
--- /dev/null
+++ b/Library/move.sh
@@ -0,0 +1,59 @@
+#!/bin/bash
+
+shopt -s extglob nullglob
+
+function df_() {
+ free=$(df -B1 "$1")
+ free=${free% *%*}
+ free=${free%%*( )}
+ free=${free##* }
+ echo "${free}"
+}
+
+function mv_() {
+ src=$1
+ dst=$2
+
+ if [[ -e ${dst} ]]; then
+ dst=$(mktemp -d /var/cydia.XXXXXX)
+ else
+ mkdir -p "${dst}"
+ fi
+
+ if [[ -e ${src} ]]; then
+ chmod --reference="${src}" "${dst}"
+ chown --reference="${src}" "${dst}"
+
+ cp -aT "${src}" "${dst}" || {
+ rm -rf "${dst}"
+ exit 1
+ }
+
+ rm -rf "${src}"
+ else
+ chmod 775 "${dst}"
+ chown root.admin "${dst}"
+ fi
+
+ ln -s "${dst}" "${src}"
+}
+
+function shift_() {
+ dir=$1
+ dst=$2
+
+ if [[ -d ${dir} && ! -h ${dir} ]]; then
+ used=$(du -bs "${dir}")
+ used=${used%%$'\t'*}
+ free=$(df_ /var)
+
+ if [[ $((used + 524288)) -lt ${free} ]]; then
+ mv_ "${dir}" "${dst}"
+ fi
+ elif [[ -h ${dir} && ! -e ${dir} ]]; then
+ rm -f "${dir}"
+ mv_ "${dir}" "${dst}"
+ fi
+}
+
+shift_ "$@"