From 7bfd28c861d354feac530836fa3d4268ea06936d Mon Sep 17 00:00:00 2001 From: "thomas.willson@me.com" Date: Thu, 13 Jun 2013 00:04:03 +0000 Subject: [PATCH] Convert to ARC except for ASIHTTPRequest library. Will need to move to an alternative library at some point as it's no longer being updated. --- AppController.h | 2 +- AppController.m | 8 +- BBCDownload.m | 2 +- Download.m | 2 +- DownloadHistoryController.m | 2 +- DownloadHistoryEntry.h | 14 +- DownloadHistoryEntry.m | 2 +- FourODDownload.m | 2 +- GTMNSString+HTML.m | 588 +++++++++++----------- Get_iPlayer GUI.xcodeproj/project.pbxproj | 20 +- HTTPRequest.h | 103 ++++ HTTPRequest.m | 171 +++++++ ITVDownload.m | 14 +- ITVMediaFileEntry.h | 6 +- JRFeedbackController.m | 50 +- LiveTVChannel.h | 2 +- LiveTVChannel.m | 4 +- NSHost+ThreadedAdditions.m | 13 +- NSString+HTML.m | 63 +-- NSURLRequest+postForm.m | 8 +- Programme.h | 42 +- Programme.m | 16 +- RadioFormat.h | 2 +- RadioFormat.m | 4 +- ReasonForFailure.h | 4 +- ReasonForFailure.m | 2 +- Series.h | 10 +- Series.m | 6 +- TVFormat.h | 2 +- TVFormat.m | 4 +- 30 files changed, 699 insertions(+), 469 deletions(-) create mode 100644 HTTPRequest.h create mode 100644 HTTPRequest.m diff --git a/AppController.h b/AppController.h index 75f65506..ac3806cc 100644 --- a/AppController.h +++ b/AppController.h @@ -194,7 +194,7 @@ bool runUpdate=NO; //- (IBAction)saveSolutionsAsText:(id)sender; //Key-Value Coding -@property (readwrite, assign) NSMutableAttributedString *log_value; +@property (readwrite) NSMutableAttributedString *log_value; @property (readonly) NSString *getiPlayerPath; @end diff --git a/AppController.m b/AppController.m index 5ea3604b..c085c91d 100644 --- a/AppController.m +++ b/AppController.m @@ -27,7 +27,7 @@ - (id)description } - (id)init { //Initialization - [super init]; + if (!(self = [super init])) return nil; NSNotificationCenter *nc; nc = [NSNotificationCenter defaultCenter]; @@ -147,7 +147,7 @@ - (void)awakeFromNib rootObject = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath]; NSArray *tempQueue = [rootObject valueForKey:@"queue"]; NSArray *tempSeries = [rootObject valueForKey:@"serieslink"]; - lastUpdate = [[rootObject valueForKey:@"lastUpdate"] retain]; + lastUpdate = [rootObject valueForKey:@"lastUpdate"]; [queueController addObjects:tempQueue]; [pvrQueueController addObjects:tempSeries]; } @@ -615,7 +615,7 @@ - (void)getiPlayerUpdateFinished isSticky:NO clickContext:nil]; [self addToLog:@"Index Updated." :self]; - lastUpdate=[[NSDate date] retain]; + lastUpdate=[NSDate date]; } else { @@ -2014,8 +2014,6 @@ - (void)pvrSearchDataReady:(NSNotification *)n } - (void)pvrSearchFinished:(NSNotification *)n { - [pvrSearchTask dealloc]; - [pvrSearchPipe dealloc]; [pvrResultsController removeObjectsAtArrangedObjectIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [[pvrResultsController arrangedObjects] count])]]; NSString *string = [NSString stringWithString:pvrSearchData]; NSUInteger length = [string length]; diff --git a/BBCDownload.m b/BBCDownload.m index 61680c79..693ddfb3 100644 --- a/BBCDownload.m +++ b/BBCDownload.m @@ -12,7 +12,7 @@ @implementation BBCDownload #pragma mark Overridden Methods - (id)initWithProgramme:(Programme *)tempShow tvFormats:(NSArray *)tvFormatList radioFormats:(NSArray *)radioFormatList proxy:(HTTPProxy *)aProxy { - [super init]; + if (!(self = [super init])) return nil; runAgain = NO; running=YES; foundLastLine=NO; diff --git a/Download.m b/Download.m index 1753b928..c762cf3f 100644 --- a/Download.m +++ b/Download.m @@ -11,7 +11,7 @@ @implementation Download - (id)init { - [super init]; + if (!(self = [super init])) return nil; //Prepare Time Remaining rateEntries = [[NSMutableArray alloc] init]; diff --git a/DownloadHistoryController.m b/DownloadHistoryController.m index e01a8b4f..917e2c41 100644 --- a/DownloadHistoryController.m +++ b/DownloadHistoryController.m @@ -14,7 +14,7 @@ @implementation DownloadHistoryController - (id)init { - [super init]; + if (!(self = [super init])) return nil; [self readHistory:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addToHistory:) name:@"AddProgToHistory" object:nil]; return self; diff --git a/DownloadHistoryEntry.h b/DownloadHistoryEntry.h index 56d2dddd..5dd02183 100644 --- a/DownloadHistoryEntry.h +++ b/DownloadHistoryEntry.h @@ -21,12 +21,12 @@ - (id)initWithPID:(NSString *)temp_pid showName:(NSString *)temp_showName episodeName:(NSString *)temp_episodeName type:(NSString *)temp_type someNumber:(NSString *)temp_someNumber downloadFormat:(NSString *)temp_downloadFormat downloadPath:(NSString *)temp_downloadPath; - (NSString *)entryString; -@property(readwrite,assign) NSString *pid; -@property(readwrite,assign) NSString *showName; -@property(readwrite,assign) NSString *episodeName; -@property(readwrite,assign) NSString *type; -@property(readwrite,assign) NSString *someNumber; -@property(readwrite,assign) NSString *downloadFormat; -@property(readwrite,assign) NSString *downloadPath; +@property(readwrite) NSString *pid; +@property(readwrite) NSString *showName; +@property(readwrite) NSString *episodeName; +@property(readwrite) NSString *type; +@property(readwrite) NSString *someNumber; +@property(readwrite) NSString *downloadFormat; +@property(readwrite) NSString *downloadPath; @end diff --git a/DownloadHistoryEntry.m b/DownloadHistoryEntry.m index 88175c17..1553e00d 100644 --- a/DownloadHistoryEntry.m +++ b/DownloadHistoryEntry.m @@ -12,7 +12,7 @@ @implementation DownloadHistoryEntry - (id)initWithPID:(NSString *)temp_pid showName:(NSString *)temp_showName episodeName:(NSString *)temp_episodeName type:(NSString *)temp_type someNumber:(NSString *)temp_someNumber downloadFormat:(NSString *)temp_downloadFormat downloadPath:(NSString *)temp_downloadPath { - [super init]; + if (!(self = [super init])) return nil; pid=[temp_pid copy]; showName=[temp_showName copy]; episodeName=[temp_episodeName copy]; diff --git a/FourODDownload.m b/FourODDownload.m index e1c10b42..8288b2a7 100644 --- a/FourODDownload.m +++ b/FourODDownload.m @@ -19,7 +19,7 @@ - (id)description } - (id)initWithProgramme:(Programme *)tempShow proxy:(HTTPProxy *)aProxy { - [super init]; + if (!(self = [super init])) return nil; proxy = aProxy; show = tempShow; diff --git a/GTMNSString+HTML.m b/GTMNSString+HTML.m index 81a71442..44dd95ac 100644 --- a/GTMNSString+HTML.m +++ b/GTMNSString+HTML.m @@ -21,337 +21,337 @@ #import "GTMNSString+HTML.h" typedef struct { - NSString *escapeSequence; - unichar uchar; + char escapeSequence[10]; + unichar uchar; } HTMLEscapeMap; // Taken from http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_Special_characters // Ordered by uchar lowest to highest for bsearching static HTMLEscapeMap gAsciiHTMLEscapeMap[] = { // A.2.2. Special characters - { @""", 34 }, - { @"&", 38 }, - { @"'", 39 }, - { @"<", 60 }, - { @">", 62 }, + { """, 34 }, + { "&", 38 }, + { "'", 39 }, + { "<", 60 }, + { ">", 62 }, // A.2.1. Latin-1 characters - { @" ", 160 }, - { @"¡", 161 }, - { @"¢", 162 }, - { @"£", 163 }, - { @"¤", 164 }, - { @"¥", 165 }, - { @"¦", 166 }, - { @"§", 167 }, - { @"¨", 168 }, - { @"©", 169 }, - { @"ª", 170 }, - { @"«", 171 }, - { @"¬", 172 }, - { @"­", 173 }, - { @"®", 174 }, - { @"¯", 175 }, - { @"°", 176 }, - { @"±", 177 }, - { @"²", 178 }, - { @"³", 179 }, - { @"´", 180 }, - { @"µ", 181 }, - { @"¶", 182 }, - { @"·", 183 }, - { @"¸", 184 }, - { @"¹", 185 }, - { @"º", 186 }, - { @"»", 187 }, - { @"¼", 188 }, - { @"½", 189 }, - { @"¾", 190 }, - { @"¿", 191 }, - { @"À", 192 }, - { @"Á", 193 }, - { @"Â", 194 }, - { @"Ã", 195 }, - { @"Ä", 196 }, - { @"Å", 197 }, - { @"Æ", 198 }, - { @"Ç", 199 }, - { @"È", 200 }, - { @"É", 201 }, - { @"Ê", 202 }, - { @"Ë", 203 }, - { @"Ì", 204 }, - { @"Í", 205 }, - { @"Î", 206 }, - { @"Ï", 207 }, - { @"Ð", 208 }, - { @"Ñ", 209 }, - { @"Ò", 210 }, - { @"Ó", 211 }, - { @"Ô", 212 }, - { @"Õ", 213 }, - { @"Ö", 214 }, - { @"×", 215 }, - { @"Ø", 216 }, - { @"Ù", 217 }, - { @"Ú", 218 }, - { @"Û", 219 }, - { @"Ü", 220 }, - { @"Ý", 221 }, - { @"Þ", 222 }, - { @"ß", 223 }, - { @"à", 224 }, - { @"á", 225 }, - { @"â", 226 }, - { @"ã", 227 }, - { @"ä", 228 }, - { @"å", 229 }, - { @"æ", 230 }, - { @"ç", 231 }, - { @"è", 232 }, - { @"é", 233 }, - { @"ê", 234 }, - { @"ë", 235 }, - { @"ì", 236 }, - { @"í", 237 }, - { @"î", 238 }, - { @"ï", 239 }, - { @"ð", 240 }, - { @"ñ", 241 }, - { @"ò", 242 }, - { @"ó", 243 }, - { @"ô", 244 }, - { @"õ", 245 }, - { @"ö", 246 }, - { @"÷", 247 }, - { @"ø", 248 }, - { @"ù", 249 }, - { @"ú", 250 }, - { @"û", 251 }, - { @"ü", 252 }, - { @"ý", 253 }, - { @"þ", 254 }, - { @"ÿ", 255 }, + { " ", 160 }, + { "¡", 161 }, + { "¢", 162 }, + { "£", 163 }, + { "¤", 164 }, + { "¥", 165 }, + { "¦", 166 }, + { "§", 167 }, + { "¨", 168 }, + { "©", 169 }, + { "ª", 170 }, + { "«", 171 }, + { "¬", 172 }, + { "­", 173 }, + { "®", 174 }, + { "¯", 175 }, + { "°", 176 }, + { "±", 177 }, + { "²", 178 }, + { "³", 179 }, + { "´", 180 }, + { "µ", 181 }, + { "¶", 182 }, + { "·", 183 }, + { "¸", 184 }, + { "¹", 185 }, + { "º", 186 }, + { "»", 187 }, + { "¼", 188 }, + { "½", 189 }, + { "¾", 190 }, + { "¿", 191 }, + { "À", 192 }, + { "Á", 193 }, + { "Â", 194 }, + { "Ã", 195 }, + { "Ä", 196 }, + { "Å", 197 }, + { "Æ", 198 }, + { "Ç", 199 }, + { "È", 200 }, + { "É", 201 }, + { "Ê", 202 }, + { "Ë", 203 }, + { "Ì", 204 }, + { "Í", 205 }, + { "Î", 206 }, + { "Ï", 207 }, + { "Ð", 208 }, + { "Ñ", 209 }, + { "Ò", 210 }, + { "Ó", 211 }, + { "Ô", 212 }, + { "Õ", 213 }, + { "Ö", 214 }, + { "×", 215 }, + { "Ø", 216 }, + { "Ù", 217 }, + { "Ú", 218 }, + { "Û", 219 }, + { "Ü", 220 }, + { "Ý", 221 }, + { "Þ", 222 }, + { "ß", 223 }, + { "à", 224 }, + { "á", 225 }, + { "â", 226 }, + { "ã", 227 }, + { "ä", 228 }, + { "å", 229 }, + { "æ", 230 }, + { "ç", 231 }, + { "è", 232 }, + { "é", 233 }, + { "ê", 234 }, + { "ë", 235 }, + { "ì", 236 }, + { "í", 237 }, + { "î", 238 }, + { "ï", 239 }, + { "ð", 240 }, + { "ñ", 241 }, + { "ò", 242 }, + { "ó", 243 }, + { "ô", 244 }, + { "õ", 245 }, + { "ö", 246 }, + { "÷", 247 }, + { "ø", 248 }, + { "ù", 249 }, + { "ú", 250 }, + { "û", 251 }, + { "ü", 252 }, + { "ý", 253 }, + { "þ", 254 }, + { "ÿ", 255 }, // A.2.2. Special characters cont'd - { @"Œ", 338 }, - { @"œ", 339 }, - { @"Š", 352 }, - { @"š", 353 }, - { @"Ÿ", 376 }, + { "Œ", 338 }, + { "œ", 339 }, + { "Š", 352 }, + { "š", 353 }, + { "Ÿ", 376 }, // A.2.3. Symbols - { @"ƒ", 402 }, + { "ƒ", 402 }, // A.2.2. Special characters cont'd - { @"ˆ", 710 }, - { @"˜", 732 }, + { "ˆ", 710 }, + { "˜", 732 }, // A.2.3. Symbols cont'd - { @"Α", 913 }, - { @"Β", 914 }, - { @"Γ", 915 }, - { @"Δ", 916 }, - { @"Ε", 917 }, - { @"Ζ", 918 }, - { @"Η", 919 }, - { @"Θ", 920 }, - { @"Ι", 921 }, - { @"Κ", 922 }, - { @"Λ", 923 }, - { @"Μ", 924 }, - { @"Ν", 925 }, - { @"Ξ", 926 }, - { @"Ο", 927 }, - { @"Π", 928 }, - { @"Ρ", 929 }, - { @"Σ", 931 }, - { @"Τ", 932 }, - { @"Υ", 933 }, - { @"Φ", 934 }, - { @"Χ", 935 }, - { @"Ψ", 936 }, - { @"Ω", 937 }, - { @"α", 945 }, - { @"β", 946 }, - { @"γ", 947 }, - { @"δ", 948 }, - { @"ε", 949 }, - { @"ζ", 950 }, - { @"η", 951 }, - { @"θ", 952 }, - { @"ι", 953 }, - { @"κ", 954 }, - { @"λ", 955 }, - { @"μ", 956 }, - { @"ν", 957 }, - { @"ξ", 958 }, - { @"ο", 959 }, - { @"π", 960 }, - { @"ρ", 961 }, - { @"ς", 962 }, - { @"σ", 963 }, - { @"τ", 964 }, - { @"υ", 965 }, - { @"φ", 966 }, - { @"χ", 967 }, - { @"ψ", 968 }, - { @"ω", 969 }, - { @"ϑ", 977 }, - { @"ϒ", 978 }, - { @"ϖ", 982 }, + { "Α", 913 }, + { "Β", 914 }, + { "Γ", 915 }, + { "Δ", 916 }, + { "Ε", 917 }, + { "Ζ", 918 }, + { "Η", 919 }, + { "Θ", 920 }, + { "Ι", 921 }, + { "Κ", 922 }, + { "Λ", 923 }, + { "Μ", 924 }, + { "Ν", 925 }, + { "Ξ", 926 }, + { "Ο", 927 }, + { "Π", 928 }, + { "Ρ", 929 }, + { "Σ", 931 }, + { "Τ", 932 }, + { "Υ", 933 }, + { "Φ", 934 }, + { "Χ", 935 }, + { "Ψ", 936 }, + { "Ω", 937 }, + { "α", 945 }, + { "β", 946 }, + { "γ", 947 }, + { "δ", 948 }, + { "ε", 949 }, + { "ζ", 950 }, + { "η", 951 }, + { "θ", 952 }, + { "ι", 953 }, + { "κ", 954 }, + { "λ", 955 }, + { "μ", 956 }, + { "ν", 957 }, + { "ξ", 958 }, + { "ο", 959 }, + { "π", 960 }, + { "ρ", 961 }, + { "ς", 962 }, + { "σ", 963 }, + { "τ", 964 }, + { "υ", 965 }, + { "φ", 966 }, + { "χ", 967 }, + { "ψ", 968 }, + { "ω", 969 }, + { "ϑ", 977 }, + { "ϒ", 978 }, + { "ϖ", 982 }, // A.2.2. Special characters cont'd - { @" ", 8194 }, - { @" ", 8195 }, - { @" ", 8201 }, - { @"‌", 8204 }, - { @"‍", 8205 }, - { @"‎", 8206 }, - { @"‏", 8207 }, - { @"–", 8211 }, - { @"—", 8212 }, - { @"‘", 8216 }, - { @"’", 8217 }, - { @"‚", 8218 }, - { @"“", 8220 }, - { @"”", 8221 }, - { @"„", 8222 }, - { @"†", 8224 }, - { @"‡", 8225 }, - // A.2.3. Symbols cont'd - { @"•", 8226 }, - { @"…", 8230 }, + { " ", 8194 }, + { " ", 8195 }, + { " ", 8201 }, + { "‌", 8204 }, + { "‍", 8205 }, + { "‎", 8206 }, + { "‏", 8207 }, + { "–", 8211 }, + { "—", 8212 }, + { "‘", 8216 }, + { "’", 8217 }, + { "‚", 8218 }, + { "“", 8220 }, + { "”", 8221 }, + { "„", 8222 }, + { "†", 8224 }, + { "‡", 8225 }, + // A.2.3. Symbols cont'd + { "•", 8226 }, + { "…", 8230 }, // A.2.2. Special characters cont'd - { @"‰", 8240 }, + { "‰", 8240 }, - // A.2.3. Symbols cont'd - { @"′", 8242 }, - { @"″", 8243 }, + // A.2.3. Symbols cont'd + { "′", 8242 }, + { "″", 8243 }, // A.2.2. Special characters cont'd - { @"‹", 8249 }, - { @"›", 8250 }, + { "‹", 8249 }, + { "›", 8250 }, - // A.2.3. Symbols cont'd - { @"‾", 8254 }, - { @"⁄", 8260 }, + // A.2.3. Symbols cont'd + { "‾", 8254 }, + { "⁄", 8260 }, // A.2.2. Special characters cont'd - { @"€", 8364 }, + { "€", 8364 }, - // A.2.3. Symbols cont'd - { @"ℑ", 8465 }, - { @"℘", 8472 }, - { @"ℜ", 8476 }, - { @"™", 8482 }, - { @"ℵ", 8501 }, - { @"←", 8592 }, - { @"↑", 8593 }, - { @"→", 8594 }, - { @"↓", 8595 }, - { @"↔", 8596 }, - { @"↵", 8629 }, - { @"⇐", 8656 }, - { @"⇑", 8657 }, - { @"⇒", 8658 }, - { @"⇓", 8659 }, - { @"⇔", 8660 }, - { @"∀", 8704 }, - { @"∂", 8706 }, - { @"∃", 8707 }, - { @"∅", 8709 }, - { @"∇", 8711 }, - { @"∈", 8712 }, - { @"∉", 8713 }, - { @"∋", 8715 }, - { @"∏", 8719 }, - { @"∑", 8721 }, - { @"−", 8722 }, - { @"∗", 8727 }, - { @"√", 8730 }, - { @"∝", 8733 }, - { @"∞", 8734 }, - { @"∠", 8736 }, - { @"∧", 8743 }, - { @"∨", 8744 }, - { @"∩", 8745 }, - { @"∪", 8746 }, - { @"∫", 8747 }, - { @"∴", 8756 }, - { @"∼", 8764 }, - { @"≅", 8773 }, - { @"≈", 8776 }, - { @"≠", 8800 }, - { @"≡", 8801 }, - { @"≤", 8804 }, - { @"≥", 8805 }, - { @"⊂", 8834 }, - { @"⊃", 8835 }, - { @"⊄", 8836 }, - { @"⊆", 8838 }, - { @"⊇", 8839 }, - { @"⊕", 8853 }, - { @"⊗", 8855 }, - { @"⊥", 8869 }, - { @"⋅", 8901 }, - { @"⌈", 8968 }, - { @"⌉", 8969 }, - { @"⌊", 8970 }, - { @"⌋", 8971 }, - { @"⟨", 9001 }, - { @"⟩", 9002 }, - { @"◊", 9674 }, - { @"♠", 9824 }, - { @"♣", 9827 }, - { @"♥", 9829 }, - { @"♦", 9830 } + // A.2.3. Symbols cont'd + { "ℑ", 8465 }, + { "℘", 8472 }, + { "ℜ", 8476 }, + { "™", 8482 }, + { "ℵ", 8501 }, + { "←", 8592 }, + { "↑", 8593 }, + { "→", 8594 }, + { "↓", 8595 }, + { "↔", 8596 }, + { "↵", 8629 }, + { "⇐", 8656 }, + { "⇑", 8657 }, + { "⇒", 8658 }, + { "⇓", 8659 }, + { "⇔", 8660 }, + { "∀", 8704 }, + { "∂", 8706 }, + { "∃", 8707 }, + { "∅", 8709 }, + { "∇", 8711 }, + { "∈", 8712 }, + { "∉", 8713 }, + { "∋", 8715 }, + { "∏", 8719 }, + { "∑", 8721 }, + { "−", 8722 }, + { "∗", 8727 }, + { "√", 8730 }, + { "∝", 8733 }, + { "∞", 8734 }, + { "∠", 8736 }, + { "∧", 8743 }, + { "∨", 8744 }, + { "∩", 8745 }, + { "∪", 8746 }, + { "∫", 8747 }, + { "∴", 8756 }, + { "∼", 8764 }, + { "≅", 8773 }, + { "≈", 8776 }, + { "≠", 8800 }, + { "≡", 8801 }, + { "≤", 8804 }, + { "≥", 8805 }, + { "⊂", 8834 }, + { "⊃", 8835 }, + { "⊄", 8836 }, + { "⊆", 8838 }, + { "⊇", 8839 }, + { "⊕", 8853 }, + { "⊗", 8855 }, + { "⊥", 8869 }, + { "⋅", 8901 }, + { "⌈", 8968 }, + { "⌉", 8969 }, + { "⌊", 8970 }, + { "⌋", 8971 }, + { "⟨", 9001 }, + { "⟩", 9002 }, + { "◊", 9674 }, + { "♠", 9824 }, + { "♣", 9827 }, + { "♥", 9829 }, + { "♦", 9830 } }; // Taken from http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_Special_characters // This is table A.2.2 Special Characters static HTMLEscapeMap gUnicodeHTMLEscapeMap[] = { // C0 Controls and Basic Latin - { @""", 34 }, - { @"&", 38 }, - { @"'", 39 }, - { @"<", 60 }, - { @">", 62 }, + { """, 34 }, + { "&", 38 }, + { "'", 39 }, + { "<", 60 }, + { ">", 62 }, // Latin Extended-A - { @"Œ", 338 }, - { @"œ", 339 }, - { @"Š", 352 }, - { @"š", 353 }, - { @"Ÿ", 376 }, + { "Œ", 338 }, + { "œ", 339 }, + { "Š", 352 }, + { "š", 353 }, + { "Ÿ", 376 }, // Spacing Modifier Letters - { @"ˆ", 710 }, - { @"˜", 732 }, + { "ˆ", 710 }, + { "˜", 732 }, // General Punctuation - { @" ", 8194 }, - { @" ", 8195 }, - { @" ", 8201 }, - { @"‌", 8204 }, - { @"‍", 8205 }, - { @"‎", 8206 }, - { @"‏", 8207 }, - { @"–", 8211 }, - { @"—", 8212 }, - { @"‘", 8216 }, - { @"’", 8217 }, - { @"‚", 8218 }, - { @"“", 8220 }, - { @"”", 8221 }, - { @"„", 8222 }, - { @"†", 8224 }, - { @"‡", 8225 }, - { @"‰", 8240 }, - { @"‹", 8249 }, - { @"›", 8250 }, - { @"€", 8364 }, + { " ", 8194 }, + { " ", 8195 }, + { " ", 8201 }, + { "‌", 8204 }, + { "‍", 8205 }, + { "‎", 8206 }, + { "‏", 8207 }, + { "–", 8211 }, + { "—", 8212 }, + { "‘", 8216 }, + { "’", 8217 }, + { "‚", 8218 }, + { "“", 8220 }, + { "”", 8221 }, + { "„", 8222 }, + { "†", 8224 }, + { "‡", 8225 }, + { "‰", 8240 }, + { "‹", 8249 }, + { "›", 8250 }, + { "€", 8364 }, }; @@ -422,7 +422,7 @@ - (NSString *)gtm_stringByEscapingHTMLUsingTable:(HTMLEscapeMap*)table buffer2Length = 0; } if (val) { - [finalString appendString:val->escapeSequence]; + [finalString appendString:[NSString stringWithCString:val->escapeSequence encoding:NSUTF8StringEncoding]]; } else { // _GTMDevAssert(escapeUnicode && buffer[i] > 127, @"Illegal Character"); @@ -506,7 +506,7 @@ - (NSString *)gtm_stringByUnescapingFromHTML { } else { // "standard" sequences for (unsigned i = 0; i < sizeof(gAsciiHTMLEscapeMap) / sizeof(HTMLEscapeMap); ++i) { - if ([escapeString isEqualToString:gAsciiHTMLEscapeMap[i].escapeSequence]) { + if ([escapeString isEqualToString:[NSString stringWithCString:gAsciiHTMLEscapeMap[i].escapeSequence encoding:NSUTF8StringEncoding]]) { [finalString replaceCharactersInRange:escapeRange withString:[NSString stringWithCharacters:&gAsciiHTMLEscapeMap[i].uchar length:1]]; break; } diff --git a/Get_iPlayer GUI.xcodeproj/project.pbxproj b/Get_iPlayer GUI.xcodeproj/project.pbxproj index 4bdcae2e..c47680fd 100644 --- a/Get_iPlayer GUI.xcodeproj/project.pbxproj +++ b/Get_iPlayer GUI.xcodeproj/project.pbxproj @@ -39,13 +39,13 @@ D914BD29100CBFA900F7E68E /* BBCDownload.m in Sources */ = {isa = PBXBuildFile; fileRef = D914BD28100CBFA900F7E68E /* BBCDownload.m */; }; D91783F01013035B00B82736 /* camstudio_record_button.png in Resources */ = {isa = PBXBuildFile; fileRef = D91783EF1013035B00B82736 /* camstudio_record_button.png */; }; D9178595101345D700B82736 /* Series.m in Sources */ = {isa = PBXBuildFile; fileRef = D9178594101345D700B82736 /* Series.m */; }; - D921C9B6149BBE9F004CB558 /* ASIDataCompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9A6149BBE9F004CB558 /* ASIDataCompressor.m */; }; - D921C9B7149BBE9F004CB558 /* ASIDataDecompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9A8149BBE9F004CB558 /* ASIDataDecompressor.m */; }; - D921C9B8149BBE9F004CB558 /* ASIDownloadCache.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9AA149BBE9F004CB558 /* ASIDownloadCache.m */; }; - D921C9B9149BBE9F004CB558 /* ASIFormDataRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9AC149BBE9F004CB558 /* ASIFormDataRequest.m */; }; - D921C9BA149BBE9F004CB558 /* ASIHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9AE149BBE9F004CB558 /* ASIHTTPRequest.m */; }; - D921C9BB149BBE9F004CB558 /* ASIInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9B2149BBE9F004CB558 /* ASIInputStream.m */; }; - D921C9BC149BBE9F004CB558 /* ASINetworkQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9B4149BBE9F004CB558 /* ASINetworkQueue.m */; }; + D921C9B6149BBE9F004CB558 /* ASIDataCompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9A6149BBE9F004CB558 /* ASIDataCompressor.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D921C9B7149BBE9F004CB558 /* ASIDataDecompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9A8149BBE9F004CB558 /* ASIDataDecompressor.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D921C9B8149BBE9F004CB558 /* ASIDownloadCache.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9AA149BBE9F004CB558 /* ASIDownloadCache.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D921C9B9149BBE9F004CB558 /* ASIFormDataRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9AC149BBE9F004CB558 /* ASIFormDataRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D921C9BA149BBE9F004CB558 /* ASIHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9AE149BBE9F004CB558 /* ASIHTTPRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D921C9BB149BBE9F004CB558 /* ASIInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9B2149BBE9F004CB558 /* ASIInputStream.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; + D921C9BC149BBE9F004CB558 /* ASINetworkQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9B4149BBE9F004CB558 /* ASINetworkQueue.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; D921C9C0149BBF43004CB558 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D921C9BF149BBF43004CB558 /* libz.dylib */; }; D921C9E8149BCB16004CB558 /* ITVDownload.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9E7149BCB16004CB558 /* ITVDownload.m */; }; D921C9EB149BCDEB004CB558 /* Download.m in Sources */ = {isa = PBXBuildFile; fileRef = D921C9EA149BCDEA004CB558 /* Download.m */; }; @@ -680,6 +680,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; CODE_SIGN_IDENTITY = "Developer ID Application: Thomas Willson"; COMBINE_HIDPI_IMAGES = YES; COPY_PHASE_STRIP = NO; @@ -688,7 +689,7 @@ "\"$(SRCROOT)\"", ); GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_OBJC_GC = supported; + GCC_ENABLE_OBJC_GC = unsupported; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -719,6 +720,7 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; CODE_SIGN_IDENTITY = "Developer ID Application: Thomas Willson"; COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -726,7 +728,7 @@ "$(inherited)", "\"$(SRCROOT)\"", ); - GCC_ENABLE_OBJC_GC = supported; + GCC_ENABLE_OBJC_GC = unsupported; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Get_iPlayer GUI_Prefix.pch"; diff --git a/HTTPRequest.h b/HTTPRequest.h new file mode 100644 index 00000000..d8324bc9 --- /dev/null +++ b/HTTPRequest.h @@ -0,0 +1,103 @@ +// +// HTTPRequest.h +// +// Created by Samuel Colak on 11/4/11. +// + +#import + +enum kHTTPCode { + kHTTPCodeUndefined = 0, + kHTTPCodeContinue = 100, + kHTTPCodeSwitchingProtocol = 101, + kHTTPCodeOK = 200, + kHTTPCodeCreated = 201, + kHTTPCodeAccepted = 202, + kHTTPCodeNonAuthoritiveAnswer = 203, + kHTTPCodeNoAnswer = 204, + kHTTPCodeResetContent = 205, + kHTTPCodePartialContent = 206, + kHTTPCodeRedirectMultipleChoices = 300, + kHTTPCodeRedirectMovedPermanently = 301, + kHTTPCodeRedirectFound = 302, + kHTTPCodeRedirectSeeOther = 303, + kHTTPCodeRedirectNotModified = 304, + kHTTPCodeRedirectUseProxy = 305, + kHTTPCodeRedirectTemporaryRedirect = 306, + kHTTPCodeClientBadRequest = 400, + kHTTPCodeClientUnauthorized = 401, + kHTTPCodeClientPaymentRequired = 402, + kHTTPCodeClientForbidden = 403, + kHTTPCodeClientNotFound = 404, + kHTTPCodeClientMethodNotAllowed = 405, + kHTTPCodeClientNotAcceptable = 406, + kHTTPCodeClientProxyAuthenticationRequired = 407, + kHTTPCodeClientRequestTimeout = 408, + kHTTPCodeClientConflict = 409, + kHTTPCodeClientGone = 410, + kHTTPCodeClientLengthRequired = 411, + kHTTPCodeClientPreconditionFailed = 412, + kHTTPCodeClientRequestEntityTooLarge = 413, + kHTTPCodeClientRequestURITooLong = 414, + kHTTPCodeClientUnsupportedMediaType = 415, + kHTTPCodeClientRequestedRangeNotSatisfiable = 416, + kHTTPCodeClientExpectationFailed = 417, + kHTTPCodeServerInternalServer = 500, + kHTTPCodeServerNotImplemented = 501, + kHTTPCodeServerBadGateway = 502, + kHTTPCodeServerServiceUnavailable = 503, + kHTTPCodeServerGatewayTimeout = 504, + kHTTPCodeServerHTTPVersionNotSupported = 505 +}; + +@interface HTTPRequest : NSObject { + + NSURL *_URL; + +@private + + NSURLConnection *_connection; + NSMutableURLRequest *_request; + NSInteger _responseCode; + NSMutableData *_responseData; + BOOL _inProgress; + +} + + @property (nonatomic, retain) NSMutableDictionary *headers; + @property (nonatomic, retain) NSString *contentType; + @property (nonatomic, retain) NSString *username; + @property (nonatomic, retain) NSString *password; + @property (nonatomic, retain) NSData *bodyContent; + + @property (nonatomic, readonly, getter = getURL) NSMutableURLRequest *URL; + @property (nonatomic, readonly, getter = getResponseData) NSData *responseData; + @property (nonatomic, readonly, getter = getResponseStatusCode) NSInteger responseStatusCode; + @property (nonatomic, readonly, getter = getInProgress) BOOL inProgress; + + + (HTTPRequest *) requestWithURL:(NSURL *)url; + + - (id) initWithURL:(NSURL *)url; + - (id) initWithURL:(NSURL *)url timeout:(float)timeout method:(NSString *)method; + + - (void) addRequestHeader:(NSString *)key value:(NSString *)data; + - (void) start; + +@end + +@protocol HTTPRequestDelegate + +@optional + - (void) request:(HTTPRequest *)request initialized:(NSURL *) url; + - (void) request:(HTTPRequest *)request connected:(NSURLResponse *)response; + - (void) request:(HTTPRequest *)request failed:(NSError *) error; + - (void) request:(HTTPRequest *)request receivedData:(NSData *)data; + - (void) request:(HTTPRequest *)request receivedChallenge:(NSURLAuthenticationChallenge *)challenge; + - (void) request:(HTTPRequest *)request authenticationFailed:(NSURLAuthenticationChallenge *)challenge; +@end + +@interface HTTPRequest () + + @property (retain, nonatomic) id delegate; + +@end \ No newline at end of file diff --git a/HTTPRequest.m b/HTTPRequest.m new file mode 100644 index 00000000..9732e367 --- /dev/null +++ b/HTTPRequest.m @@ -0,0 +1,171 @@ +// +// HTTPRequest.m +// +// Created by Samuel Colak on 11/4/11. +// + +#import "HTTPRequest.h" + +@implementation HTTPRequest + + @synthesize delegate; + @synthesize headers=_headers; + @synthesize contentType=_contentType; + + @synthesize password=_password; + @synthesize username=_username; + @synthesize bodyContent=_bodyContent; + + #pragma mark - Instantiation + + + (HTTPRequest *) requestWithURL:(NSURL *)url + { + return [[HTTPRequest alloc] initWithURL:url]; + } + + - (id) initWithURL:(NSURL *)url + { + return [self initWithURL:url timeout:60.0 method:@"PUT"]; + } + + - (id) initWithURL:(NSURL *)url timeout:(float)timeout method:(NSString *)method + { + self = [super init]; + if (self) { + _URL = url; + _responseCode = kHTTPCodeUndefined; + _responseData = nil; + _inProgress = NO; + _contentType = @"text/plain; charset=utf-8"; + _headers = [[NSMutableDictionary alloc] init]; + _request = [NSMutableURLRequest requestWithURL:_URL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:timeout]; + [_request setHTTPMethod:method]; + } + return self; + } + + #pragma mark - Properties and getters + + - (NSURL *) getURL + { + return _URL; + } + + - (BOOL) getInProgress + { + return _inProgress; + } + + - (NSData *) getResponseData + { + return _responseData; + } + + - (NSInteger) getResponseStatusCode + { + return _responseCode; + } + + #pragma mark - Functions + + - (void) addRequestHeader:(NSString *)key value:(NSString *)data + { + [_headers setValue:data forKey:key]; + } + + - (void) start + { + + if (_inProgress) return; + _inProgress = YES; + + _responseCode = kHTTPCodeUndefined; + _responseData = nil; + + [_request addValue:_contentType forHTTPHeaderField:@"Content-Type"]; + + if (_headers.count > 0) { + for (NSString *key in _headers.allKeys) + { + [_request addValue:[_headers valueForKey:key] forHTTPHeaderField:key]; + } + } + + if (_bodyContent != nil) { + [_request addValue:[NSString stringWithFormat:@"%d", _bodyContent.length] forHTTPHeaderField:@"Content-Length"]; + [_request setHTTPBody: _bodyContent]; + } + + _connection = [[NSURLConnection alloc] initWithRequest:_request delegate:self]; + + if (_connection) { + if (delegate && [delegate respondsToSelector:@selector(request:initialized:)]) { + [delegate request:self initialized:_URL]; + } + } else { + // connection failed ... + _responseCode = kHTTPCodeServerServiceUnavailable; + if (delegate && [delegate respondsToSelector:@selector(request:failed:)]) { + [delegate request:self failed:nil]; + } + _inProgress = NO; + } + + } + + #pragma mark - Delegate related functions + + - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge + { + // if you want to execute your own challenge functionality here.... + if (delegate && [delegate respondsToSelector:@selector(request:receivedChallenge:)]) { + [delegate request:self receivedChallenge:challenge]; + } else { + // automate the response using the username / password information.. + if ([challenge previousFailureCount] == 0 && ![challenge proposedCredential]) { + NSURLCredential *_credentials = [NSURLCredential credentialWithUser:_username password:_password persistence:NSURLCredentialPersistenceNone]; + [[challenge sender] useCredential:_credentials forAuthenticationChallenge:challenge]; + } else { + if (delegate && [delegate respondsToSelector:@selector(request:authenticationFailed:)]) { + [delegate request:self authenticationFailed:challenge]; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; + } + } + } + } + + - (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data + { + [_responseData appendData:data]; + } + + - (void) connectionDidFinishLoading:(NSURLConnection *)connection + { + if (delegate && [delegate respondsToSelector:@selector(request:receivedData:)]) { + [delegate request:self receivedData:_responseData]; + } + } + + - (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response + { + _responseData = [[NSMutableData alloc] init]; + NSHTTPURLResponse *_httpResponse = (NSHTTPURLResponse *)response; + _responseCode = [_httpResponse statusCode]; + if (delegate && [delegate respondsToSelector:@selector(request:connected:)]) { + [delegate request:self connected:response]; + } + _inProgress = NO; + } + + - (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error + { + _responseCode = kHTTPCodeServerInternalServer; + if (delegate && [delegate respondsToSelector:@selector(request:failed:)]) { + [delegate request:self failed:error]; + } + _inProgress = NO; + } + + +@end diff --git a/ITVDownload.m b/ITVDownload.m index da015650..c352a357 100644 --- a/ITVDownload.m +++ b/ITVDownload.m @@ -15,7 +15,7 @@ @implementation ITVDownload - (id)init { - [super init]; + if (!(self = [super init])) return nil; return self; } @@ -25,7 +25,7 @@ - (id)description } - (id)initWithProgramme:(Programme *)tempShow itvFormats:(NSArray *)itvFormatList proxy:(HTTPProxy *)aProxy { - [super init]; + if (!(self = [super init])) return nil; proxy = aProxy; show = tempShow; @@ -226,7 +226,10 @@ -(void)metaRequestFinished:(ASIHTTPRequest *)request [scanner scanUpToString:@"" intoString:nil]; [scanner scanUpToString:@"CDATA" intoString:nil]; [scanner scanString:@"CDATA[" intoString:nil]; - [scanner scanUpToString:@"]]" intoString:&thumbnailURL]; + NSString *url; + [scanner scanUpToString:@"]]" intoString:&url]; + thumbnailURL=url; + url=nil; //Increase thumbnail size to 640x360 NSInteger thumbWidth = 0; @@ -253,7 +256,10 @@ -(void)metaRequestFinished:(ASIHTTPRequest *)request { [scanner scanUpToString:@"CDATA[" intoString:nil]; [scanner scanString:@"CDATA[" intoString:nil]; - [scanner scanUpToString:@"]]" intoString:&subtitleURL]; + NSString *url; + [scanner scanUpToString:@"]]" intoString:&url]; + subtitleURL=url; + url=nil; } //Retrieve Auth URL NSString *authURL = nil; diff --git a/ITVMediaFileEntry.h b/ITVMediaFileEntry.h index 070ebda0..a63b24ec 100644 --- a/ITVMediaFileEntry.h +++ b/ITVMediaFileEntry.h @@ -13,7 +13,7 @@ NSString *itvRate; NSString *url; } -@property (readwrite,assign) NSString *bitrate; -@property (readwrite,assign) NSString *itvRate; -@property (readwrite,assign) NSString *url; +@property (readwrite) NSString *bitrate; +@property (readwrite) NSString *itvRate; +@property (readwrite) NSString *url; @end diff --git a/JRFeedbackController.m b/JRFeedbackController.m index f3c8c217..f9d34405 100755 --- a/JRFeedbackController.m +++ b/JRFeedbackController.m @@ -93,16 +93,16 @@ - (void)windowDidLoad { NSString *separator = @"\n\n--\n\n"; NSRange separatorRange = [[text string] rangeOfString:separator]; - sectionStrings[JRFeedbackController_BugReport] = [[text attributedSubstringFromRange:NSMakeRange(0, separatorRange.location)] retain]; + sectionStrings[JRFeedbackController_BugReport] = [text attributedSubstringFromRange:NSMakeRange(0, separatorRange.location)]; [text deleteCharactersInRange:NSMakeRange(0, separatorRange.location + [separator length])]; //NSLog(@"bugReport: <%@>", [sectionStrings[JRFeedbackController_BugReport] string]); separatorRange = [[text string] rangeOfString:separator]; - sectionStrings[JRFeedbackController_FeatureRequest] = [[text attributedSubstringFromRange:NSMakeRange(0, separatorRange.location)] retain]; + sectionStrings[JRFeedbackController_FeatureRequest] = [text attributedSubstringFromRange:NSMakeRange(0, separatorRange.location)]; [text deleteCharactersInRange:NSMakeRange(0, separatorRange.location + [separator length])]; //NSLog(@"featureRequest: <%@>", [sectionStrings[JRFeedbackController_FeatureRequest] string]); - sectionStrings[JRFeedbackController_SupportRequest] = [[text attributedSubstringFromRange:NSMakeRange(0, [text length])] retain]; + sectionStrings[JRFeedbackController_SupportRequest] = [text attributedSubstringFromRange:NSMakeRange(0, [text length])]; //NSLog(@"supportRequest: <%@>", [sectionStrings[JRFeedbackController_SupportRequest] string]); [text setAttributedString:sectionStrings[JRFeedbackController_BugReport]]; @@ -131,7 +131,6 @@ - (void)setIncludeContactInfo:(BOOL)flag { } - (IBAction)switchSectionAction:(NSSegmentedControl*)sender { - [sectionStrings[currentSection] release]; sectionStrings[currentSection] = [[textView textStorage] copy]; currentSection = [sender selectedSegment]; @@ -151,7 +150,6 @@ - (IBAction)submitAction:(id)sender [sendButton setEnabled:NO]; [cancelButton setEnabled:NO]; - [sectionStrings[currentSection] release]; sectionStrings[currentSection] = [[textView textStorage] copy]; [textView setEditable:NO]; @@ -182,27 +180,27 @@ - (IBAction)submitAction:(id)sender } - (void)system_profilerThread:(id)ignored { - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + @autoreleasepool { - NSString *systemProfile = nil; - { - NSPipe *inputPipe = [NSPipe pipe]; - NSPipe *outputPipe = [NSPipe pipe]; - - NSTask *scriptTask = [[[NSTask alloc] init] autorelease]; - [scriptTask setLaunchPath:@"/usr/sbin/system_profiler"]; - [scriptTask setArguments:@[@"-detailLevel", @"mini"]]; - [scriptTask setStandardOutput:outputPipe]; - [scriptTask launch]; - - [[inputPipe fileHandleForWriting] closeFile]; - systemProfile = [[[NSString alloc] initWithData:[[outputPipe fileHandleForReading] readDataToEndOfFile] - encoding:NSUTF8StringEncoding] autorelease]; + NSString *systemProfile = nil; + { + NSPipe *inputPipe = [NSPipe pipe]; + NSPipe *outputPipe = [NSPipe pipe]; + + NSTask *scriptTask = [[NSTask alloc] init]; + [scriptTask setLaunchPath:@"/usr/sbin/system_profiler"]; + [scriptTask setArguments:@[@"-detailLevel", @"mini"]]; + [scriptTask setStandardOutput:outputPipe]; + [scriptTask launch]; + + [[inputPipe fileHandleForWriting] closeFile]; + systemProfile = [[NSString alloc] initWithData:[[outputPipe fileHandleForReading] readDataToEndOfFile] + encoding:NSUTF8StringEncoding]; + } + [self performSelectorOnMainThread:@selector(postFeedback:) + withObject:systemProfile + waitUntilDone:NO]; } - [self performSelectorOnMainThread:@selector(postFeedback:) - withObject:systemProfile - waitUntilDone:NO]; - [pool drain]; } - (void)postFeedback:(NSString*)systemProfile { @@ -241,7 +239,6 @@ - (void)closeFeedback { if (gFeedbackController) { assert(gFeedbackController == self); [[gFeedbackController window] orderOut:self]; - [gFeedbackController release]; gFeedbackController = nil; } } @@ -278,7 +275,7 @@ - (void)displayAlertMessage:(NSString *)message withInformativeText:(NSString *)text andAlertStyle:(NSAlertStyle)alertStyle { - NSAlert *thankYouAlert = [[[NSAlert alloc] init] autorelease]; + NSAlert *thankYouAlert = [[NSAlert alloc] init]; [thankYouAlert addButtonWithTitle:@"OK"]; [thankYouAlert setMessageText:message]; [thankYouAlert setInformativeText:text]; @@ -314,7 +311,6 @@ - (void)setTextViewStringTo:(NSString *)details NSFont *resetFontWeight = [[textView textStorage] font]; [[textView textStorage] setFont:[NSFont fontWithName:[resetFontWeight familyName] size:[resetFontWeight pointSize]]]; [textView setString:details]; - [resetFontWeight release]; } + (NSURL*)postURL { diff --git a/LiveTVChannel.h b/LiveTVChannel.h index 3e758296..a12331b3 100644 --- a/LiveTVChannel.h +++ b/LiveTVChannel.h @@ -12,6 +12,6 @@ @interface LiveTVChannel : NSObject { NSString *channel; } -@property (readwrite, assign) NSString *channel; +@property (readwrite) NSString *channel; -(id)initWithChannelName:(NSString *)channelName; @end diff --git a/LiveTVChannel.m b/LiveTVChannel.m index 8a634846..08912e57 100644 --- a/LiveTVChannel.m +++ b/LiveTVChannel.m @@ -12,13 +12,13 @@ @implementation LiveTVChannel - (id)init { - [super init]; + if (!(self = [super init])) return nil; channel = [[NSString alloc] init]; return self; } - (id)initWithChannelName:(NSString *)channelName { - [super init]; + if (!(self = [super init])) return nil; channel = [channelName copy]; return self; } diff --git a/NSHost+ThreadedAdditions.m b/NSHost+ThreadedAdditions.m index 416826d9..c69fb65c 100644 --- a/NSHost+ThreadedAdditions.m +++ b/NSHost+ThreadedAdditions.m @@ -51,11 +51,11 @@ - (id)initWithReceiver:(id)aReceiver receiverSelector:(SEL)aReceiverSelector self = [super init]; if (self) { - receiver = [aReceiver retain]; + receiver = aReceiver; receiverSelector = aReceiverSelector; - receivingThread = [aReceivingThread retain]; + receivingThread = aReceivingThread; lookupSelector = aLookupSelector; - parameter = [aParameter retain]; + parameter = aParameter; } return self; } @@ -69,13 +69,6 @@ - (void)main waitUntilDone:NO]; } -- (void)dealloc -{ - [receiver release]; - [receivingThread release]; - [parameter release]; - [super dealloc]; -} @end diff --git a/NSString+HTML.m b/NSString+HTML.m index 469a9c7a..0cae31b6 100644 --- a/NSString+HTML.m +++ b/NSString+HTML.m @@ -36,9 +36,6 @@ @implementation NSString (HTML) - (NSString *)stringByConvertingHTMLToPlainText { - // Pool - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - // Character sets NSCharacterSet *stopCharacters = [NSCharacterSet characterSetWithCharactersInString:[NSString stringWithFormat:@"< \t\n\r%C%C%C%C", 0x0085, 0x000C, 0x2028, 0x2029]]; NSCharacterSet *newLineAndWhitespaceCharacters = [NSCharacterSet characterSetWithCharactersInString:[NSString stringWithFormat:@" \t\n\r%C%C%C%C", 0x0085, 0x000C, 0x2028, 0x2029]]; @@ -114,18 +111,13 @@ - (NSString *)stringByConvertingHTMLToPlainText { } while (![scanner isAtEnd]); - // Cleanup - [scanner release]; // Decode HTML entities and return - NSString *retString = [[result stringByDecodingHTMLEntities] retain]; - [result release]; + NSString *retString = [result stringByDecodingHTMLEntities]; - // Drain - [pool drain]; // Return - return [retString autorelease]; + return retString; } @@ -147,9 +139,6 @@ - (NSString *)stringByEncodingHTMLEntities:(BOOL)isUnicode { - (NSString *)stringWithNewLinesAsBRs { - // Pool - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - // Strange New lines: // Next Line, U+0085 // Form Feed, U+000C @@ -192,23 +181,14 @@ - (NSString *)stringWithNewLinesAsBRs { } while (![scanner isAtEnd]); // Cleanup & return - [scanner release]; - NSString *retString = [[NSString stringWithString:result] retain]; - [result release]; - - // Drain - [pool drain]; + NSString *retString = [NSString stringWithString:result]; // Return - return [retString autorelease]; + return retString; } -- (NSString *)stringByRemovingNewLinesAndWhitespace { - - // Pool - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - +- (NSString *)stringByRemovingNewLinesAndWhitespace { // Strange New lines: // Next Line, U+0085 // Form Feed, U+000C @@ -238,37 +218,24 @@ - (NSString *)stringByRemovingNewLinesAndWhitespace { } - // Cleanup - [scanner release]; - // Return - NSString *retString = [[NSString stringWithString:result] retain]; - [result release]; - - // Drain - [pool drain]; + NSString *retString = [NSString stringWithString:result]; // Return - return [retString autorelease]; + return retString; } - (NSString *)stringByLinkifyingURLs { if (!NSClassFromString(@"NSRegularExpression")) return self; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *pattern = @"(?$1"] retain]; - [pool drain]; - return [modifiedString autorelease]; + NSString *modifiedString = [regex stringByReplacingMatchesInString:self options:0 range:NSMakeRange(0, [self length]) + withTemplate:@"$1"]; + return modifiedString; } - (NSString *)stringByStrippingTags { - - // Pool - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - // Find first & and short-cut if we can NSUInteger ampIndex = [self rangeOfString:@"<" options:NSLiteralSearch].location; if (ampIndex == NSNotFound) { @@ -291,7 +258,6 @@ - (NSString *)stringByStrippingTags { if (tag) { NSString *t = [[NSString alloc] initWithFormat:@"%@>", tag]; [tags addObject:t]; - [t release]; } } while (![scanner isAtEnd]); @@ -325,17 +291,12 @@ - (NSString *)stringByStrippingTags { } // Remove multi-spaces and line breaks - finalString = [[result stringByRemovingNewLinesAndWhitespace] retain]; + finalString = [result stringByRemovingNewLinesAndWhitespace]; // Cleanup - [result release]; - [tags release]; - - // Drain - [pool drain]; // Return - return [finalString autorelease]; + return finalString; } diff --git a/NSURLRequest+postForm.m b/NSURLRequest+postForm.m index 769d0456..2c2f85b7 100755 --- a/NSURLRequest+postForm.m +++ b/NSURLRequest+postForm.m @@ -19,7 +19,7 @@ - (void)appendString:(NSString*)string { - (void)appendFormat:(NSString *)format, ... { va_list args; va_start(args, format); - NSString *string = [[[NSString alloc] initWithFormat:format arguments:args] autorelease]; + NSString *string = [[NSString alloc] initWithFormat:format arguments:args]; va_end(args); [self appendString:string]; } @@ -49,12 +49,12 @@ + (id)requestWithURL:(NSURL*)url postForm:(NSDictionary*)values { // TODO scan `values` to ensure uniqueness of `boundary`. Loop+regen UUID if collision is discovered. CFUUIDRef cfUuid = CFUUIDCreate(kCFAllocatorDefault); - NSString * uuid = (id)CFUUIDCreateString(kCFAllocatorDefault, cfUuid); + NSString * uuid = (id)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, cfUuid)); CFRelease(cfUuid); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - uuid = NSMakeCollectable(uuid); + uuid = CFBridgingRelease(CFBridgingRetain(uuid)); #endif - uuid = [uuid autorelease]; + uuid = uuid; NSString *boundary = [NSString stringWithFormat:@"x-mime-boundary://%@", uuid]; //-- diff --git a/Programme.h b/Programme.h index 40fc9541..0fb931ca 100644 --- a/Programme.h +++ b/Programme.h @@ -29,33 +29,33 @@ NSString *reasonForFailure; NSString *availableModes; NSString *url; - NSDate *dateAired; + NSDate *__strong dateAired; NSString *desc; NSNumber *podcast; } - (id)initWithInfo:(id)sender pid:(NSString *)PID programmeName:(NSString *)SHOWNAME network:(NSString *)TVNETWORK; - (id)initWithShow:(Programme *)show; -@property (readwrite, assign) NSString *showName; -@property (readwrite, assign) NSString *tvNetwork; -@property (readwrite, assign) NSString *pid; -@property (readwrite, assign) NSString *status; -@property (readwrite, assign) NSString *seriesName; -@property (readwrite, assign) NSString *episodeName; -@property (readwrite, assign) NSNumber *complete; -@property (readwrite, assign) NSNumber *successful; -@property (readwrite, assign) NSNumber *timeadded; -@property (readwrite, assign) NSString *path; +@property (readwrite) NSString *showName; +@property (readwrite) NSString *tvNetwork; +@property (readwrite) NSString *pid; +@property (readwrite) NSString *status; +@property (readwrite) NSString *seriesName; +@property (readwrite) NSString *episodeName; +@property (readwrite) NSNumber *complete; +@property (readwrite) NSNumber *successful; +@property (readwrite) NSNumber *timeadded; +@property (readwrite) NSString *path; @property (readwrite, assign) NSInteger season; @property (readwrite, assign) NSInteger episode; -@property (readwrite, assign) NSNumber *processedPID; -@property (readwrite, assign) NSNumber *radio; -@property (readwrite, assign) NSString *realPID; -@property (readwrite, assign) NSString *subtitlePath; -@property (readwrite, assign) NSString *reasonForFailure; -@property (readwrite, assign) NSString *availableModes; -@property (readwrite, assign) NSString *url; -@property (readwrite, assign) NSDate *dateAired; -@property (readwrite, assign) NSString *desc; -@property (readwrite, assign) NSNumber *podcast; +@property (readwrite) NSNumber *processedPID; +@property (readwrite) NSNumber *radio; +@property (readwrite) NSString *realPID; +@property (readwrite) NSString *subtitlePath; +@property (readwrite) NSString *reasonForFailure; +@property (readwrite) NSString *availableModes; +@property (readwrite) NSString *url; +@property (readwrite, strong) NSDate *dateAired; +@property (readwrite) NSString *desc; +@property (readwrite) NSNumber *podcast; @end diff --git a/Programme.m b/Programme.m index eed4e490..5726c68c 100644 --- a/Programme.m +++ b/Programme.m @@ -14,7 +14,7 @@ @implementation Programme - (id)initWithInfo:(id)sender pid:(NSString *)PID programmeName:(NSString *)SHOWNAME network:(NSString *)TVNETWORK { - [super init]; + if (!(self = [super init])) return nil; pid = [PID stringByReplacingOccurrencesOfString:@";amp" withString:@""]; showName = [[[NSString alloc] initWithString:SHOWNAME] stringByDecodingHTMLEntities]; tvNetwork = [[NSString alloc] initWithString:TVNETWORK]; @@ -109,7 +109,7 @@ - (void) encodeWithCoder: (NSCoder *)coder } - (id) initWithCoder: (NSCoder *)coder { - [super init]; + if (!(self = [super init])) return nil; pid = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"pid"]]; showName = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"showName"]]; tvNetwork = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"tvNetwork"]]; @@ -119,16 +119,16 @@ - (id) initWithCoder: (NSCoder *)coder path = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"path"]]; seriesName = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"seriesName"]]; episodeName = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"episodeName"]]; - timeadded = [[coder decodeObjectForKey:@"timeadded"] retain]; - processedPID = [[coder decodeObjectForKey:@"processedPID"] retain]; - radio = [[coder decodeObjectForKey:@"radio"] retain]; - realPID = [[coder decodeObjectForKey:@"realPID"] retain]; - url = [[coder decodeObjectForKey:@"url"] retain]; + timeadded = [coder decodeObjectForKey:@"timeadded"]; + processedPID = [coder decodeObjectForKey:@"processedPID"]; + radio = [coder decodeObjectForKey:@"radio"]; + realPID = [coder decodeObjectForKey:@"realPID"]; + url = [coder decodeObjectForKey:@"url"]; subtitlePath=[[NSString alloc] init]; reasonForFailure=[[NSString alloc] init]; availableModes=[[NSString alloc] init]; desc=[[NSString alloc] init]; - podcast = [[coder decodeObjectForKey:@"podcast"] retain]; + podcast = [coder decodeObjectForKey:@"podcast"]; return self; } /* diff --git a/RadioFormat.h b/RadioFormat.h index 8763ba35..eb0908d2 100644 --- a/RadioFormat.h +++ b/RadioFormat.h @@ -12,5 +12,5 @@ @interface RadioFormat : NSObject { NSString *format; } -@property (readwrite, assign) NSString *format; +@property (readwrite) NSString *format; @end diff --git a/RadioFormat.m b/RadioFormat.m index c2fb3039..a7ccf666 100644 --- a/RadioFormat.m +++ b/RadioFormat.m @@ -12,7 +12,7 @@ @implementation RadioFormat - (id)init { - [super init]; + if (!(self = [super init])) return nil; format = [[NSString alloc] init]; return self; } @@ -23,7 +23,7 @@ - (void) encodeWithCoder: (NSCoder *)coder } - (id) initWithCoder: (NSCoder *)coder { - [super init]; + if (!(self = [super init])) return nil; format = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"format"]]; return self; } diff --git a/ReasonForFailure.h b/ReasonForFailure.h index d870aeee..af180a56 100644 --- a/ReasonForFailure.h +++ b/ReasonForFailure.h @@ -13,7 +13,7 @@ NSString *solution; } -@property (readwrite,assign) NSString *showName; -@property (readwrite,assign) NSString *solution; +@property (readwrite) NSString *showName; +@property (readwrite) NSString *solution; @end diff --git a/ReasonForFailure.m b/ReasonForFailure.m index b6cbaff2..8ab80b50 100644 --- a/ReasonForFailure.m +++ b/ReasonForFailure.m @@ -12,7 +12,7 @@ @implementation ReasonForFailure - (id)init { - [super init]; + if (!(self = [super init])) return nil; showName = [[NSString alloc] init]; solution = [[NSString alloc] init]; return self; diff --git a/Series.h b/Series.h index adfa56f2..de34beec 100644 --- a/Series.h +++ b/Series.h @@ -12,12 +12,12 @@ @interface Series : NSObject { NSString *showName; NSString *tvNetwork; - NSNumber *added; + NSNumber *__strong added; NSDate *lastFound; } - (id)initWithShowname:(NSString *)SHOWNAME; -@property (readwrite, assign) NSString *showName; -@property (readwrite, assign) NSNumber *added; -@property (readwrite, assign) NSString *tvNetwork; -@property (readwrite, assign) NSDate *lastFound; +@property (readwrite) NSString *showName; +@property (readwrite, strong) NSNumber *added; +@property (readwrite) NSString *tvNetwork; +@property (readwrite) NSDate *lastFound; @end diff --git a/Series.m b/Series.m index 0c272e03..fddf2c3d 100644 --- a/Series.m +++ b/Series.m @@ -12,7 +12,7 @@ @implementation Series - (id)init { - [super init]; + if (!(self = [super init])) return nil; showName = [[NSString alloc] init]; tvNetwork = [[NSString alloc] init]; lastFound = [[NSDate alloc] init]; @@ -20,7 +20,7 @@ - (id)init } - (id)initWithShowname:(NSString *)SHOWNAME { - [super init]; + if (!(self = [super init])) return nil; showName = [[NSString alloc] initWithString:SHOWNAME]; tvNetwork = [[NSString alloc] init]; lastFound = [NSDate date]; @@ -35,7 +35,7 @@ - (void) encodeWithCoder: (NSCoder *)coder } - (id) initWithCoder: (NSCoder *)coder { - [super init]; + if (!(self = [super init])) return nil; showName = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"showName"]]; added = [coder decodeObjectForKey:@"added"]; tvNetwork = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"tvNetwork"]]; diff --git a/TVFormat.h b/TVFormat.h index 196d292b..ab27539e 100644 --- a/TVFormat.h +++ b/TVFormat.h @@ -12,5 +12,5 @@ @interface TVFormat : NSObject { NSString *format; } -@property (readwrite, assign) NSString *format; +@property (readwrite) NSString *format; @end diff --git a/TVFormat.m b/TVFormat.m index 97cb6513..1c833cda 100644 --- a/TVFormat.m +++ b/TVFormat.m @@ -12,7 +12,7 @@ @implementation TVFormat - (id)init { - [super init]; + if (!(self = [super init])) return nil; format = [[NSString alloc] init]; return self; } @@ -22,7 +22,7 @@ - (void) encodeWithCoder: (NSCoder *)coder } - (id) initWithCoder: (NSCoder *)coder { - [super init]; + if (!(self = [super init])) return nil; format = [[NSString alloc] initWithString:[coder decodeObjectForKey:@"format"]]; return self; }