From 1c206c25f41295878337fd38b0e0fdb23540cf06 Mon Sep 17 00:00:00 2001 From: Orta Therox Date: Sun, 1 Jul 2012 11:40:55 +0100 Subject: [PATCH] unRARing possibly broke. Uses HTTPS. Support native m4v. Sliding view does all items. Transfers that failed are not shown. Accounts popover fixed positions --- Puttio/FileController/BaseFileController.m | 1 - Puttio/FileController/ComicFileController.mm | 4 +- Puttio/FileController/UnknownFileController.m | 2 +- Puttio/FileController/VideoFileController.m | 8 +- Puttio/Models/Transfer.h | 7 ++ Puttio/Networking/PutIONetworkConstants.m | 2 +- Puttio/Networking/PutIOOAuthHelper.m | 4 +- Puttio/Networking/V2PutIOAPIClient.m | 9 +- Puttio/Utils/V1PutIOAPIClient.m | 2 +- .../ViewControllers/AccountViewController.m | 2 +- Puttio/ViewControllers/StatusViewController.m | 9 +- Puttio/Views/ORSlidingTableView.m | 3 +- Puttio/en.lproj/MainStoryboard.storyboard | 4 +- vendor/UnRAR/unrarsrc-3.9.10/os.hpp | 4 +- vendor/UnRAR/unrarsrc-3.9.10/uowners.cpp | 114 +++++++++--------- 15 files changed, 93 insertions(+), 82 deletions(-) diff --git a/Puttio/FileController/BaseFileController.m b/Puttio/FileController/BaseFileController.m index 2992c6a..0fca1cb 100644 --- a/Puttio/FileController/BaseFileController.m +++ b/Puttio/FileController/BaseFileController.m @@ -43,7 +43,6 @@ - (void)secondaryButtonAction:(id)sender {} -(NSString *)descriptiveTextForFile { return @"NO TEXT SET"; } - (void)getInfoWithBlock:(void(^)(id infoObject))onComplete { - NSLog(@"info!"); // [[PutIOClient sharedClient] getInfoForFile:_file :^(id userInfoObject) { // NSLog(@"asdafsfAF"); // if (![userInfoObject isMemberOfClass:[NSError class]]) { diff --git a/Puttio/FileController/ComicFileController.mm b/Puttio/FileController/ComicFileController.mm index 816fef6..9fdc6ba 100644 --- a/Puttio/FileController/ComicFileController.mm +++ b/Puttio/FileController/ComicFileController.mm @@ -69,7 +69,7 @@ - (NSString *)primaryButtonText { - (void)primaryButtonAction:(id)sender { [self markFileAsViewed]; - NSString *requestURL = [NSString stringWithFormat:@"http://put.io/v2/files/%@/download", _file.id]; + NSString *requestURL = [NSString stringWithFormat:@"https://put.io/v2/files/%@/download", _file.id]; [self downloadFileAtPath:requestURL WithCompletionBlock:^(AFHTTPRequestOperation *operation, id responseObject) { NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:_file.id]; @@ -103,7 +103,7 @@ - (NSString *)secondaryButtonText { } - (void)secondaryButtonAction:(id)sender { - NSString *requestURL = [NSString stringWithFormat:@"http://put.io/v2/files/%@/download", _file.id]; + NSString *requestURL = [NSString stringWithFormat:@"https://put.io/v2/files/%@/download", _file.id]; [self downloadFileAtPath:requestURL WithCompletionBlock:^(AFHTTPRequestOperation *operation, id responseObject) { NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:_file.name]; diff --git a/Puttio/FileController/UnknownFileController.m b/Puttio/FileController/UnknownFileController.m index ae80eb2..12be6ff 100644 --- a/Puttio/FileController/UnknownFileController.m +++ b/Puttio/FileController/UnknownFileController.m @@ -30,7 +30,7 @@ - (void)setFile:(File *)aFile { [self.infoController showProgress]; [self.infoController disableButtons]; - NSString *requestURL = [NSString stringWithFormat:@"http://put.io/v2/files/%@/download", _file.id]; + NSString *requestURL = [NSString stringWithFormat:@"https://put.io/v2/files/%@/download", _file.id]; [self downloadFileAtPath:requestURL WithCompletionBlock:^(AFHTTPRequestOperation *operation, id responseObject) { downloadedFilepath = [NSTemporaryDirectory() stringByAppendingPathComponent:_file.name]; [operation.responseData writeToFile:downloadedFilepath atomically:YES]; diff --git a/Puttio/FileController/VideoFileController.m b/Puttio/FileController/VideoFileController.m index 90a2f72..6021684 100644 --- a/Puttio/FileController/VideoFileController.m +++ b/Puttio/FileController/VideoFileController.m @@ -62,9 +62,9 @@ - (NSString *)primaryButtonText { - (void)primaryButtonAction:(id)sender { if (_isMP4) { - [MoviePlayer streamMovieAtPath:[NSString stringWithFormat:@"http://put.io/v2/files/%@/stream", _file.id]]; + [MoviePlayer streamMovieAtPath:[NSString stringWithFormat:@"https://put.io/v2/files/%@/stream", _file.id]]; }else{ - [MoviePlayer streamMovieAtPath:[NSString stringWithFormat:@"http://put.io/v2/files/%@/mp4/stream", _file.id]]; + [MoviePlayer streamMovieAtPath:[NSString stringWithFormat:@"https://put.io/v2/files/%@/mp4/stream", _file.id]]; } [self markFileAsViewed]; @@ -90,9 +90,9 @@ - (void)secondaryButtonAction:(id)sender { - (void)downloadFile { NSString *requestURL; if (_isMP4) { - requestURL = [NSString stringWithFormat:@"http://put.io/v2/files/%@/download", _file.id]; + requestURL = [NSString stringWithFormat:@"https://put.io/v2/files/%@/download", _file.id]; }else{ - requestURL = [NSString stringWithFormat:@"http://put.io/v2/files/%@/mp4/download", _file.id]; + requestURL = [NSString stringWithFormat:@"https://put.io/v2/files/%@/mp4/download", _file.id]; } [self downloadFileAtPath:requestURL WithCompletionBlock:^(AFHTTPRequestOperation *operation, id responseObject) { diff --git a/Puttio/Models/Transfer.h b/Puttio/Models/Transfer.h index ec7dacf..3df0a16 100644 --- a/Puttio/Models/Transfer.h +++ b/Puttio/Models/Transfer.h @@ -10,10 +10,17 @@ @interface Transfer : NSObject +typedef enum { + TransferStatusOK, + TransferStatusERROR +} TransferStatus; + + @property (strong) NSNumber* estimatedTime; @property (strong) NSString* name; @property (strong) NSString* createdAt; @property (strong) NSNumber* percentDone; @property (strong) NSNumber* downloadSpeed; @property (strong) NSString* displayName; +@property (assign) TransferStatus status; @end diff --git a/Puttio/Networking/PutIONetworkConstants.m b/Puttio/Networking/PutIONetworkConstants.m index 38e70e2..f258406 100644 --- a/Puttio/Networking/PutIONetworkConstants.m +++ b/Puttio/Networking/PutIONetworkConstants.m @@ -15,4 +15,4 @@ NSString *const PTFormatOauthTokenURL = @"https://api.put.io/v2/oauth2/access_token?client_id=%@&client_secret=%@&grant_type=%@&redirect_uri=%@&code=%@"; NSString *const PTFormatOauthLoginURL = @"https://api.put.io/v2/oauth2/authenticate?client_id=%@&response_type=code&redirect_uri=%@"; -NSString *const PTFormatOauthURL = @"https://api.put.io/v2/oauth2/authenticate?client_id=%@&response_type=code&redirect_uri=%@"; +NSString *const PTFormatOauthURL = @"https://api.put.io/v2/oauth2/authenticate?client_id=%@&response_type=code&redirect_uri=%@"; \ No newline at end of file diff --git a/Puttio/Networking/PutIOOAuthHelper.m b/Puttio/Networking/PutIOOAuthHelper.m index 0ed433e..8938650 100644 --- a/Puttio/Networking/PutIOOAuthHelper.m +++ b/Puttio/Networking/PutIOOAuthHelper.m @@ -11,7 +11,7 @@ #import "AFNetworking.h" #import "PutIONetworkConstants.h" -// http://put.io/v2/docs/#authentication +// https://put.io/v2/docs/#authentication // The order of this is @@ -42,7 +42,7 @@ - (void)loginWithUsername:(NSString *)username andPassword:(NSString *)password - (void)getAccessTokenFromOauthCode:(NSString *)code { // https://api.put.io/v2/oauth2/access_token?client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=authorization_code&redirect_uri=YOUR_REGISTERED_REDIRECT_URI&code=CODE - + // NSString *address = [NSString stringWithFormat:PTFormatOauthTokenURL, @"10", APP_SECRET, @"authorization_code", PTCallbackOriginal, code]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:address]]; diff --git a/Puttio/Networking/V2PutIOAPIClient.m b/Puttio/Networking/V2PutIOAPIClient.m index a4befb3..13a0ad7 100644 --- a/Puttio/Networking/V2PutIOAPIClient.m +++ b/Puttio/Networking/V2PutIOAPIClient.m @@ -6,7 +6,7 @@ // Copyright (c) 2012 ortatherox.com. All rights reserved. // -// http://put.io/v2/docs/ +// https://put.io/v2/docs/ #import "V2PutIOAPIClient.h" #import "PutIONetworkConstants.h" @@ -28,7 +28,7 @@ @implementation V2PutIOAPIClient @synthesize apiToken, actionBlocks; + (id)setup { - V2PutIOAPIClient *api = [[V2PutIOAPIClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://api.put.io/"]]; + V2PutIOAPIClient *api = [[V2PutIOAPIClient alloc] initWithBaseURL:[NSURL URLWithString:@"https://api.put.io/"]]; if (api) { [[NSNotificationCenter defaultCenter] addObserver:api @@ -155,6 +155,11 @@ - (void)getTransfers :(void(^)(id userInfoObject))onComplete { transfer.estimatedTime = transferDict[@"estimated_time"]; transfer.createdAt = transferDict[@"created_at"]; transfer.displayName = [File createDisplayNameFromName:transfer.name]; + if (transferDict[@"error_message"] != [NSNull null]) { + transfer.status = TransferStatusERROR; + }else { + transfer.status = TransferStatusOK; + } [returnedTransfers addObject:transfer]; } } diff --git a/Puttio/Utils/V1PutIOAPIClient.m b/Puttio/Utils/V1PutIOAPIClient.m index c0a4d52..07fc8fd 100644 --- a/Puttio/Utils/V1PutIOAPIClient.m +++ b/Puttio/Utils/V1PutIOAPIClient.m @@ -10,7 +10,7 @@ #import "AFJSONRequestOperation.h" #import "NSDictionary+JSON.h" -// http://put.io/v2/docs/ +// https://put.io/v2/docs/ NSString* API_V1_ADDRESS = @"http://api.put.io/v1/"; @interface V1PutIOAPIClient () diff --git a/Puttio/ViewControllers/AccountViewController.m b/Puttio/ViewControllers/AccountViewController.m index 88487b7..f1155d4 100644 --- a/Puttio/ViewControllers/AccountViewController.m +++ b/Puttio/ViewControllers/AccountViewController.m @@ -39,7 +39,7 @@ - (void)viewWillAppear:(BOOL)animated { // Space Left on Put.io NSString *deviceUsedString = [[NSUserDefaults standardUserDefaults] objectForKey:ORDiskQuotaAvailableDefault]; - self.accountSpaceLabel.text = [NSString stringWithFormat:@"You are using %@ on the site", [UIDevice humanStringFromBytes:[deviceUsedString doubleValue]]]; + self.accountSpaceLabel.text = [NSString stringWithFormat:@"You have %@ left on the site", [UIDevice humanStringFromBytes:[deviceUsedString doubleValue]]]; self.accountSpaceLeftProgress.progress = [[NSUserDefaults standardUserDefaults] doubleForKey:ORCurrentSpaceUsedPercentageDefault]; self.accountSpaceLeftProgress.isLandscape = YES; diff --git a/Puttio/ViewControllers/StatusViewController.m b/Puttio/ViewControllers/StatusViewController.m index 529d50e..3417b81 100644 --- a/Puttio/ViewControllers/StatusViewController.m +++ b/Puttio/ViewControllers/StatusViewController.m @@ -81,15 +81,14 @@ - (void)viewWillAppear:(BOOL)animated { } - (void)didTapProgressView:(UITapGestureRecognizer*)gesture { - - NSLog(@"ASDASD"); UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]]; UIViewController *accountVC = [storyboard instantiateViewControllerWithIdentifier:@"accountView"]; popoverController = [[WEPopoverController alloc] initWithContentViewController:accountVC]; - - [popoverController presentPopoverFromRect:gesture.view.superview.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES]; + UINavigationController *rootController = (UINavigationController*)[UIApplication sharedApplication].keyWindow.rootViewController; + + [popoverController presentPopoverFromRect:[rootController.view convertRect:gesture.view.frame fromView:gesture.view.superview] inView:rootController.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES]; } - (void)startTimer { @@ -125,6 +124,8 @@ - (NSArray *)onlyRecentTransfers: (NSArray*)inTransfers { NSDate *threeDaysAgo = [calendar dateByAddingComponents:minusDaysComponents toDate:today options:0]; for (Transfer *transfer in inTransfers) { + if (transfer.status == TransferStatusERROR) continue; + if (transfer.percentDone.intValue != 100) { [newTransfers addObject:transfer]; }else{ diff --git a/Puttio/Views/ORSlidingTableView.m b/Puttio/Views/ORSlidingTableView.m index b1a9e54..2238586 100644 --- a/Puttio/Views/ORSlidingTableView.m +++ b/Puttio/Views/ORSlidingTableView.m @@ -55,7 +55,7 @@ - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { } // loop through all the cells subtracting the height - for (cellIndex = 0; cellIndex < cellCount - 1; cellIndex++) { + for (cellIndex = 0; cellIndex < cellCount; cellIndex++) { fingerY -= cellHeight; if (fingerY < 0) break; } @@ -78,5 +78,4 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [self.slidingDelegate slidingTableDidEndTouch:self]; } - @end diff --git a/Puttio/en.lproj/MainStoryboard.storyboard b/Puttio/en.lproj/MainStoryboard.storyboard index 8a19cb6..0f2c429 100644 --- a/Puttio/en.lproj/MainStoryboard.storyboard +++ b/Puttio/en.lproj/MainStoryboard.storyboard @@ -1,8 +1,8 @@ - + - + diff --git a/vendor/UnRAR/unrarsrc-3.9.10/os.hpp b/vendor/UnRAR/unrarsrc-3.9.10/os.hpp index 47603f7..5613d91 100644 --- a/vendor/UnRAR/unrarsrc-3.9.10/os.hpp +++ b/vendor/UnRAR/unrarsrc-3.9.10/os.hpp @@ -166,8 +166,8 @@ #else #endif -#include -#include +//#include +//#include #include #include #include diff --git a/vendor/UnRAR/unrarsrc-3.9.10/uowners.cpp b/vendor/UnRAR/unrarsrc-3.9.10/uowners.cpp index 38471e0..fd2dd3d 100644 --- a/vendor/UnRAR/unrarsrc-3.9.10/uowners.cpp +++ b/vendor/UnRAR/unrarsrc-3.9.10/uowners.cpp @@ -8,35 +8,35 @@ void ExtractUnixOwner(Archive &Arc,char *FileName) ErrHandler.SetErrorCode(CRC_ERROR); return; } - - struct passwd *pw; - if ((pw=getpwnam(Arc.UOHead.OwnerName))==NULL) - { - Log(Arc.FileName,St(MErrGetOwnerID),Arc.UOHead.OwnerName); - ErrHandler.SetErrorCode(WARNING); - return; - } - uid_t OwnerID=pw->pw_uid; - - struct group *gr; - if ((gr=getgrnam(Arc.UOHead.GroupName))==NULL) - { - Log(Arc.FileName,St(MErrGetGroupID),Arc.UOHead.GroupName); - ErrHandler.SetErrorCode(CRC_ERROR); - return; - } - uint Attr=GetFileAttr(FileName,NULL); - gid_t GroupID=gr->gr_gid; -#if defined(SAVE_LINKS) && !defined(_APPLE) - if (lchown(FileName,OwnerID,GroupID)!=0) -#else - if (chown(FileName,OwnerID,GroupID)!=0) -#endif - { - Log(Arc.FileName,St(MSetOwnersError),FileName); - ErrHandler.SetErrorCode(CREATE_ERROR); - } - SetFileAttr(FileName,NULL,Attr); +// +// struct passwd *pw; +// if ((pw=getpwnam(Arc.UOHead.OwnerName))==NULL) +// { +// Log(Arc.FileName,St(MErrGetOwnerID),Arc.UOHead.OwnerName); +// ErrHandler.SetErrorCode(WARNING); +// return; +// } +// uid_t OwnerID=pw->pw_uid; +// +// struct group *gr; +// if ((gr=getgrnam(Arc.UOHead.GroupName))==NULL) +// { +// Log(Arc.FileName,St(MErrGetGroupID),Arc.UOHead.GroupName); +// ErrHandler.SetErrorCode(CRC_ERROR); +// return; +// } +// uint Attr=GetFileAttr(FileName,NULL); +// gid_t GroupID=gr->gr_gid; +//#if defined(SAVE_LINKS) && !defined(_APPLE) +// if (lchown(FileName,OwnerID,GroupID)!=0) +//#else +// if (chown(FileName,OwnerID,GroupID)!=0) +//#endif +// { +// Log(Arc.FileName,St(MSetOwnersError),FileName); +// ErrHandler.SetErrorCode(CREATE_ERROR); +// } +// SetFileAttr(FileName,NULL,Attr); } @@ -49,32 +49,32 @@ void ExtractUnixOwnerNew(Archive &Arc,char *FileName) strncpy(GroupName,(char *)&Arc.SubHead.SubData[OwnerSize],GroupSize); GroupName[GroupSize]=0; - struct passwd *pw; - if ((pw=getpwnam(OwnerName))==NULL) - { - Log(Arc.FileName,St(MErrGetOwnerID),OwnerName); - ErrHandler.SetErrorCode(WARNING); - return; - } - uid_t OwnerID=pw->pw_uid; - - struct group *gr; - if ((gr=getgrnam(GroupName))==NULL) - { - Log(Arc.FileName,St(MErrGetGroupID),GroupName); - ErrHandler.SetErrorCode(CRC_ERROR); - return; - } - uint Attr=GetFileAttr(FileName,NULL); - gid_t GroupID=gr->gr_gid; -#if defined(SAVE_LINKS) && !defined(_APPLE) - if (lchown(FileName,OwnerID,GroupID)!=0) -#else - if (chown(FileName,OwnerID,GroupID)!=0) -#endif - { - Log(Arc.FileName,St(MSetOwnersError),FileName); - ErrHandler.SetErrorCode(CREATE_ERROR); - } - SetFileAttr(FileName,NULL,Attr); +// struct passwd *pw; +// if ((pw=getpwnam(OwnerName))==NULL) +// { +// Log(Arc.FileName,St(MErrGetOwnerID),OwnerName); +// ErrHandler.SetErrorCode(WARNING); +// return; +// } +// uid_t OwnerID=pw->pw_uid; +// +// struct group *gr; +// if ((gr=getgrnam(GroupName))==NULL) +// { +// Log(Arc.FileName,St(MErrGetGroupID),GroupName); +// ErrHandler.SetErrorCode(CRC_ERROR); +// return; +// } +// uint Attr=GetFileAttr(FileName,NULL); +// gid_t GroupID=gr->gr_gid; +//#if defined(SAVE_LINKS) && !defined(_APPLE) +// if (lchown(FileName,OwnerID,GroupID)!=0) +//#else +// if (chown(FileName,OwnerID,GroupID)!=0) +//#endif +// { +// Log(Arc.FileName,St(MSetOwnersError),FileName); +// ErrHandler.SetErrorCode(CREATE_ERROR); +// } +// SetFileAttr(FileName,NULL,Attr); }