Sfoglia il codice sorgente

【综合】串接激活相关数据

niehaoyu 1 anno fa
parent
commit
387bd26860
23 ha cambiato i file con 9307 aggiunte e 619 eliminazioni
  1. 86 0
      PDF Office/PDF Master.xcodeproj/project.pbxproj
  2. 98 0
      PDF Office/PDF Master.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  3. 2 0
      PDF Office/PDF Master/AppDelegate.swift
  4. 586 596
      PDF Office/PDF Master/Class/Purchase/DMG/Verification/VerificationManager/VerificationManager.m
  5. 42 23
      PDF Office/PDF Master/Class/Purchase/IAPProductsManager.m
  6. 103 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASICacheDelegate.h
  7. 42 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIDataCompressor.h
  8. 219 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIDataCompressor.m
  9. 41 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIDataDecompressor.h
  10. 218 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIDataDecompressor.m
  11. 46 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIDownloadCache.h
  12. 514 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIDownloadCache.m
  13. 75 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIFormDataRequest.h
  14. 362 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIFormDataRequest.m
  15. 1004 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIHTTPRequest.h
  16. 5138 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIHTTPRequest.m
  17. 43 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIHTTPRequestConfig.h
  18. 35 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIHTTPRequestDelegate.h
  19. 26 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIInputStream.h
  20. 138 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIInputStream.m
  21. 108 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASINetworkQueue.h
  22. 343 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASINetworkQueue.m
  23. 38 0
      PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIProgressDelegate.h

+ 86 - 0
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -3355,6 +3355,27 @@
 		BB671A012AD2D2A0003D44D5 /* CPDFStampAnnotation+PDFListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB671A002AD2D2A0003D44D5 /* CPDFStampAnnotation+PDFListView.swift */; };
 		BB671A022AD2D2A0003D44D5 /* CPDFStampAnnotation+PDFListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB671A002AD2D2A0003D44D5 /* CPDFStampAnnotation+PDFListView.swift */; };
 		BB671A032AD2D2A0003D44D5 /* CPDFStampAnnotation+PDFListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB671A002AD2D2A0003D44D5 /* CPDFStampAnnotation+PDFListView.swift */; };
+		BB67EE172B54FFEF00573BF0 /* ASIDataCompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE052B54FFEF00573BF0 /* ASIDataCompressor.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE182B54FFEF00573BF0 /* ASIDataCompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE052B54FFEF00573BF0 /* ASIDataCompressor.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE192B54FFEF00573BF0 /* ASIDataCompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE052B54FFEF00573BF0 /* ASIDataCompressor.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE1A2B54FFEF00573BF0 /* ASIHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE062B54FFEF00573BF0 /* ASIHTTPRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE1B2B54FFEF00573BF0 /* ASIHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE062B54FFEF00573BF0 /* ASIHTTPRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE1C2B54FFEF00573BF0 /* ASIHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE062B54FFEF00573BF0 /* ASIHTTPRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE1D2B54FFEF00573BF0 /* ASIFormDataRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE092B54FFEF00573BF0 /* ASIFormDataRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE1E2B54FFEF00573BF0 /* ASIFormDataRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE092B54FFEF00573BF0 /* ASIFormDataRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE1F2B54FFEF00573BF0 /* ASIFormDataRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE092B54FFEF00573BF0 /* ASIFormDataRequest.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE202B54FFEF00573BF0 /* ASIDataDecompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE0B2B54FFEF00573BF0 /* ASIDataDecompressor.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE212B54FFEF00573BF0 /* ASIDataDecompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE0B2B54FFEF00573BF0 /* ASIDataDecompressor.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE222B54FFEF00573BF0 /* ASIDataDecompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE0B2B54FFEF00573BF0 /* ASIDataDecompressor.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE232B54FFEF00573BF0 /* ASIInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE0C2B54FFEF00573BF0 /* ASIInputStream.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE242B54FFEF00573BF0 /* ASIInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE0C2B54FFEF00573BF0 /* ASIInputStream.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE252B54FFEF00573BF0 /* ASIInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE0C2B54FFEF00573BF0 /* ASIInputStream.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE262B54FFEF00573BF0 /* ASINetworkQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE132B54FFEF00573BF0 /* ASINetworkQueue.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE272B54FFEF00573BF0 /* ASINetworkQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE132B54FFEF00573BF0 /* ASINetworkQueue.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE282B54FFEF00573BF0 /* ASINetworkQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE132B54FFEF00573BF0 /* ASINetworkQueue.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE292B54FFEF00573BF0 /* ASIDownloadCache.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE152B54FFEF00573BF0 /* ASIDownloadCache.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE2A2B54FFEF00573BF0 /* ASIDownloadCache.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE152B54FFEF00573BF0 /* ASIDownloadCache.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
+		BB67EE2B2B54FFEF00573BF0 /* ASIDownloadCache.m in Sources */ = {isa = PBXBuildFile; fileRef = BB67EE152B54FFEF00573BF0 /* ASIDownloadCache.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
 		BB69C95C299116FD0001A9B1 /* five_line_score.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BB69C959299116FD0001A9B1 /* five_line_score.pdf */; };
 		BB69C95D299116FD0001A9B1 /* five_line_score.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BB69C959299116FD0001A9B1 /* five_line_score.pdf */; };
 		BB69C95E299116FD0001A9B1 /* five_line_score.pdf in Resources */ = {isa = PBXBuildFile; fileRef = BB69C959299116FD0001A9B1 /* five_line_score.pdf */; };
@@ -6056,6 +6077,24 @@
 		BB6719F82AD2CC05003D44D5 /* CPDFSignatureWidgetAnnotation+PDFListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CPDFSignatureWidgetAnnotation+PDFListView.swift"; sourceTree = "<group>"; };
 		BB6719FC2AD2CE1B003D44D5 /* CPDFSquareAnnotation+PDFListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CPDFSquareAnnotation+PDFListView.swift"; sourceTree = "<group>"; };
 		BB671A002AD2D2A0003D44D5 /* CPDFStampAnnotation+PDFListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CPDFStampAnnotation+PDFListView.swift"; sourceTree = "<group>"; };
+		BB67EE052B54FFEF00573BF0 /* ASIDataCompressor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIDataCompressor.m; sourceTree = "<group>"; };
+		BB67EE062B54FFEF00573BF0 /* ASIHTTPRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIHTTPRequest.m; sourceTree = "<group>"; };
+		BB67EE072B54FFEF00573BF0 /* ASIHTTPRequestDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIHTTPRequestDelegate.h; sourceTree = "<group>"; };
+		BB67EE082B54FFEF00573BF0 /* ASINetworkQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASINetworkQueue.h; sourceTree = "<group>"; };
+		BB67EE092B54FFEF00573BF0 /* ASIFormDataRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIFormDataRequest.m; sourceTree = "<group>"; };
+		BB67EE0A2B54FFEF00573BF0 /* ASIHTTPRequestConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIHTTPRequestConfig.h; sourceTree = "<group>"; };
+		BB67EE0B2B54FFEF00573BF0 /* ASIDataDecompressor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIDataDecompressor.m; sourceTree = "<group>"; };
+		BB67EE0C2B54FFEF00573BF0 /* ASIInputStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIInputStream.m; sourceTree = "<group>"; };
+		BB67EE0D2B54FFEF00573BF0 /* ASIDownloadCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIDownloadCache.h; sourceTree = "<group>"; };
+		BB67EE0E2B54FFEF00573BF0 /* ASIHTTPRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIHTTPRequest.h; sourceTree = "<group>"; };
+		BB67EE0F2B54FFEF00573BF0 /* ASICacheDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASICacheDelegate.h; sourceTree = "<group>"; };
+		BB67EE102B54FFEF00573BF0 /* ASIDataCompressor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIDataCompressor.h; sourceTree = "<group>"; };
+		BB67EE112B54FFEF00573BF0 /* ASIProgressDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIProgressDelegate.h; sourceTree = "<group>"; };
+		BB67EE122B54FFEF00573BF0 /* ASIFormDataRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIFormDataRequest.h; sourceTree = "<group>"; };
+		BB67EE132B54FFEF00573BF0 /* ASINetworkQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASINetworkQueue.m; sourceTree = "<group>"; };
+		BB67EE142B54FFEF00573BF0 /* ASIDataDecompressor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIDataDecompressor.h; sourceTree = "<group>"; };
+		BB67EE152B54FFEF00573BF0 /* ASIDownloadCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIDownloadCache.m; sourceTree = "<group>"; };
+		BB67EE162B54FFEF00573BF0 /* ASIInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIInputStream.h; sourceTree = "<group>"; };
 		BB69C959299116FD0001A9B1 /* five_line_score.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = five_line_score.pdf; sourceTree = "<group>"; };
 		BB69C95A299116FD0001A9B1 /* plaid.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = plaid.pdf; sourceTree = "<group>"; };
 		BB69C95B299116FD0001A9B1 /* horizontal_line.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = horizontal_line.pdf; sourceTree = "<group>"; };
@@ -6815,6 +6854,7 @@
 		89752DA22936ECD5003FF08E /* Third Pard Library */ = {
 			isa = PBXGroup;
 			children = (
+				BB67EE042B54FFEF00573BF0 /* ASIHttpRequest */,
 				ADFCEB422B4FBA430001EBAF /* RemoteConfig  */,
 				ADDDCE1A2B43A32A005B4AB5 /* AppSandboxFileAccess */,
 				9FC444F82AA5F7D600D7187C /* ZipArchive.framework */,
@@ -10643,6 +10683,31 @@
 			path = EmailSubscription;
 			sourceTree = "<group>";
 		};
+		BB67EE042B54FFEF00573BF0 /* ASIHttpRequest */ = {
+			isa = PBXGroup;
+			children = (
+				BB67EE052B54FFEF00573BF0 /* ASIDataCompressor.m */,
+				BB67EE062B54FFEF00573BF0 /* ASIHTTPRequest.m */,
+				BB67EE072B54FFEF00573BF0 /* ASIHTTPRequestDelegate.h */,
+				BB67EE082B54FFEF00573BF0 /* ASINetworkQueue.h */,
+				BB67EE092B54FFEF00573BF0 /* ASIFormDataRequest.m */,
+				BB67EE0A2B54FFEF00573BF0 /* ASIHTTPRequestConfig.h */,
+				BB67EE0B2B54FFEF00573BF0 /* ASIDataDecompressor.m */,
+				BB67EE0C2B54FFEF00573BF0 /* ASIInputStream.m */,
+				BB67EE0D2B54FFEF00573BF0 /* ASIDownloadCache.h */,
+				BB67EE0E2B54FFEF00573BF0 /* ASIHTTPRequest.h */,
+				BB67EE0F2B54FFEF00573BF0 /* ASICacheDelegate.h */,
+				BB67EE102B54FFEF00573BF0 /* ASIDataCompressor.h */,
+				BB67EE112B54FFEF00573BF0 /* ASIProgressDelegate.h */,
+				BB67EE122B54FFEF00573BF0 /* ASIFormDataRequest.h */,
+				BB67EE132B54FFEF00573BF0 /* ASINetworkQueue.m */,
+				BB67EE142B54FFEF00573BF0 /* ASIDataDecompressor.h */,
+				BB67EE152B54FFEF00573BF0 /* ASIDownloadCache.m */,
+				BB67EE162B54FFEF00573BF0 /* ASIInputStream.h */,
+			);
+			path = ASIHttpRequest;
+			sourceTree = "<group>";
+		};
 		BB69C958299116FD0001A9B1 /* Resource */ = {
 			isa = PBXGroup;
 			children = (
@@ -13822,6 +13887,7 @@
 				ADBC373C29CA9AE100D93208 /* KMComparativeManager.swift in Sources */,
 				BB147008299DC0D100784A6A /* OIDRegistrationRequest.m in Sources */,
 				BBA19F4729AE27DA001A285A /* KMAnnotationTableRowView.swift in Sources */,
+				BB67EE172B54FFEF00573BF0 /* ASIDataCompressor.m in Sources */,
 				BB8F4565295AA3ED0037EA22 /* KMHeaderFooterManager.swift in Sources */,
 				F34BF926295303E8002C25A2 /* NSCursor+PDFListView.m in Sources */,
 				9F705F8D291E579F005199AD /* KMHistoryFileTableView.swift in Sources */,
@@ -13999,6 +14065,7 @@
 				AD867FB329DFBB2700F00440 /* KMAnnotationOutlineSectionView.swift in Sources */,
 				BBEC00A8295BDECF00A26C98 /* KMHeaderFooterContentInfoView.swift in Sources */,
 				9FDD0F6F294AD13C000C4DAD /* KMMainViewController+Action.swift in Sources */,
+				BB67EE1D2B54FFEF00573BF0 /* ASIFormDataRequest.m in Sources */,
 				ADDF839B2B391A5D00A81A4E /* PDFCertExportAccessoryView.swift in Sources */,
 				9F0CB4E52986557F00007028 /* KMDesignToken+PaddingRight.swift in Sources */,
 				BB86C1ED28F544F4005AD968 /* CPDFListView+Event.m in Sources */,
@@ -14189,6 +14256,7 @@
 				BBBF68842A3C3AF10058E14E /* NSDocumentController+KMExtension.swift in Sources */,
 				ADA9102A2A272CE2003352F0 /* KMEditPDFTextManager.swift in Sources */,
 				BB24FFE62B2863EF00A59054 /* KMTTSManager.swift in Sources */,
+				BB67EE202B54FFEF00573BF0 /* ASIDataDecompressor.m in Sources */,
 				BB897229294B08720045787C /* KMWatermarkAdjectiveTopBarItemModel.swift in Sources */,
 				BB00301D298CB799002DD1A0 /* KMPreferenceManager.swift in Sources */,
 				BBF729A32B19624500576AC5 /* KMAddBackgroundOperationQueue.swift in Sources */,
@@ -14254,6 +14322,7 @@
 				ADD1B6E42946C00800C3FFF7 /* KMPrintChoosePageSizePosterView.swift in Sources */,
 				9F1FE4BA29406E4700E952CA /* NSImage+CTAdditions.m in Sources */,
 				ADDF832F2B391A5C00A81A4E /* NSGeometry+PDFListView.m in Sources */,
+				BB67EE232B54FFEF00573BF0 /* ASIInputStream.m in Sources */,
 				BB6B4C08292F53CE0071CA06 /* KMMergeFileModel.swift in Sources */,
 				BB981E552AD4F638001988CA /* KMPageIndicator.swift in Sources */,
 				AD0E8AB42A31B78900DBFD3C /* KMDMGPurchaseManager.swift in Sources */,
@@ -14348,6 +14417,7 @@
 				BB2F18462A0C7E250003F65E /* KMConvertBaseView.swift in Sources */,
 				BB99ACCA292DEE6E0048AFD9 /* KMMergeTitleBar.swift in Sources */,
 				ADBC174F2A2991F700959CEE /* KMPurchaseManager.swift in Sources */,
+				BB67EE262B54FFEF00573BF0 /* ASINetworkQueue.m in Sources */,
 				BB4DD043299B291A00E80DF6 /* KMCloudNoNetworkView.swift in Sources */,
 				BB49ECF6293F44DC00C82CA2 /* KMConvertExcelWindowController.swift in Sources */,
 				BB8810D62B4F984000AFA63E /* JSONKit.m in Sources */,
@@ -14356,6 +14426,7 @@
 				9F0CB49F29683E2600007028 /* KMPropertiesPanelSizeSubVC.swift in Sources */,
 				BB2EDF54296E815E003BCF58 /* KMPageEditBaseItemView.swift in Sources */,
 				9F1FE4EA29406E4700E952CA /* NSBezierPath+MCAdditions.m in Sources */,
+				BB67EE292B54FFEF00573BF0 /* ASIDownloadCache.m in Sources */,
 				BBCE57102A72712200508EFC /* NSWindowController+KMExtension.swift in Sources */,
 				BBEFD0182AF9BD24003FABD8 /* KMDataVersionManager.swift in Sources */,
 				BBAFFB1B29CDD19C00C56112 /* KMMergeSelect.swift in Sources */,
@@ -14812,6 +14883,7 @@
 				ADD1B70A29471FA500C3FFF7 /* KMPrintChoosePresenter.swift in Sources */,
 				BB1BFF692AEA02F8003EB179 /* KMBatchOperateSplitViewController.swift in Sources */,
 				F3599173292B62F5000D25DE /* CStringConstants.m in Sources */,
+				BB67EE1A2B54FFEF00573BF0 /* ASIHTTPRequest.m in Sources */,
 				BB1B0AFB2B4FC6E900889528 /* KMCustomColorGuideView.swift in Sources */,
 				9F0CB4D92986553600007028 /* KMDesignToken+VerticalPadding.swift in Sources */,
 				BBF19E992B0B3218007154C8 /* KMAnnotationStamp.swift in Sources */,
@@ -14904,6 +14976,7 @@
 				BB853C642AF87428009C20C1 /* KMBatchOperateRemoveWatermarkViewController.swift in Sources */,
 				ADAFDA3F2AE8F32400F084BC /* KMAdvertisementManager.swift in Sources */,
 				BBA19F4829AE27DA001A285A /* KMAnnotationTableRowView.swift in Sources */,
+				BB67EE242B54FFEF00573BF0 /* ASIInputStream.m in Sources */,
 				ADE86A812B02220700414DFA /* KMSecurityView.swift in Sources */,
 				BBE9D0982AF0CECB002E83CE /* KMBatchOperateCompressViewController.swift in Sources */,
 				BB8F4566295AA3ED0037EA22 /* KMHeaderFooterManager.swift in Sources */,
@@ -15254,6 +15327,7 @@
 				BB147015299DC0D100784A6A /* OIDAuthState.m in Sources */,
 				BB3AAB9129878CE000992A5A /* KMWatermarkAdjectivePropertyMainController.swift in Sources */,
 				BB147039299DC0D200784A6A /* OIDAuthorizationResponse.m in Sources */,
+				BB67EE182B54FFEF00573BF0 /* ASIDataCompressor.m in Sources */,
 				9F1FE4B229406E4700E952CA /* CTTabWindowController.m in Sources */,
 				BB2EDF6E296ECE17003BCF58 /* KMPageEditInsertDirectionItemView.swift in Sources */,
 				BB6013912AD3AFF000A76FB2 /* NSPopover+KMExtension.swift in Sources */,
@@ -15554,6 +15628,7 @@
 				BBF8A4042AE8E10100788BAC /* KMBatchConvertParameter.swift in Sources */,
 				AD3AAD642B0DA3F600DE5FE7 /* KMCompareTextHeaderView.swift in Sources */,
 				ADE86AC92B034CB200414DFA /* KMAddBackgroundView.swift in Sources */,
+				BB67EE212B54FFEF00573BF0 /* ASIDataDecompressor.m in Sources */,
 				BB88E45929404752002B3655 /* KMPDFConvert.swift in Sources */,
 				9F080B15298CFDB300FC27DA /* KMTextImageButtonVC.swift in Sources */,
 				BB27BF3D2B33E85200A0BAAE /* CPDFView+KMExtension.swift in Sources */,
@@ -15654,8 +15729,10 @@
 				BBFBE74628DD7DB7008B2335 /* AppDelegate.swift in Sources */,
 				BBC4F9EB2AEB58290098A1A8 /* KMAlertWindowController.swift in Sources */,
 				BB6719EA2AD2A57C003D44D5 /* CPDFLinkAnnotation+PDFListView.swift in Sources */,
+				BB67EE2A2B54FFEF00573BF0 /* ASIDownloadCache.m in Sources */,
 				ADD1B6B829420B2300C3FFF7 /* KMPrintChooseView.swift in Sources */,
 				9FCFEC9D2AD152FA00EAD2CB /* CustomAlertView.swift in Sources */,
+				BB67EE1B2B54FFEF00573BF0 /* ASIHTTPRequest.m in Sources */,
 				BB147000299DC0D100784A6A /* OIDRedirectHTTPHandler.m in Sources */,
 				BB147003299DC0D100784A6A /* OIDScopeUtilities.m in Sources */,
 				BB1B0AF62B4FC6E900889528 /* KMConvertGuideView.swift in Sources */,
@@ -15732,6 +15809,7 @@
 				BBB9B31D299A5D6D004F3235 /* KMCloudOperation.m in Sources */,
 				ADDF83AB2B391A5D00A81A4E /* DSignatureModel.swift in Sources */,
 				AD9527BB295291F20039D2BC /* KMPrintPage.swift in Sources */,
+				BB67EE1E2B54FFEF00573BF0 /* ASIFormDataRequest.m in Sources */,
 				ADE3C1AC29A4779E00793B13 /* KMPrintAccessoryController.swift in Sources */,
 				BB10FAF72AFE2C2900F18D65 /* KMNumberArrayFormatter.swift in Sources */,
 				BBD7FE082A13241C00F96075 /* KMOutlineEditViewController.swift in Sources */,
@@ -15801,6 +15879,7 @@
 				ADDEEA672AD3C4BE00EF675D /* KMPDFSignatureImageView.swift in Sources */,
 				BB403BAB2B15CA6E00B3106D /* KMBatchConvertOperation.swift in Sources */,
 				ADDEEA732AD3EFE200EF675D /* KMButton.swift in Sources */,
+				BB67EE272B54FFEF00573BF0 /* ASINetworkQueue.m in Sources */,
 				BB2F9AB92AFCC3AD00F9DD93 /* KMProfileInfo.swift in Sources */,
 				BB146FE5299DC0D100784A6A /* GTLRURITemplate.m in Sources */,
 				9F1FE4F129406E4700E952CA /* BackgroundGradientView.m in Sources */,
@@ -16095,6 +16174,7 @@
 				BB8F4580295B00130037EA22 /* KMWatermarkAdjectiveTools.swift in Sources */,
 				BBB9B312299A5D6D004F3235 /* KMCloudDownloadOperationQueue.m in Sources */,
 				BB147046299DC0D200784A6A /* OIDURLQueryComponent.m in Sources */,
+				BB67EE2B2B54FFEF00573BF0 /* ASIDownloadCache.m in Sources */,
 				BB99ACD1292E2AEF0048AFD9 /* KMMergeCollectionViewItem.swift in Sources */,
 				9F0CB51F2986569B00007028 /* KMDesignToken+BorderRadiusBottomRight.swift in Sources */,
 				BB86C1EF28F544F4005AD968 /* CPDFListView+Event.m in Sources */,
@@ -16120,6 +16200,7 @@
 				ADDEEA642AD3A6E700EF675D /* KMPDFSignatureTextView.swift in Sources */,
 				9FAAA334290BD0A20046FFCE /* KMHistoryFileCollectionViewItem.swift in Sources */,
 				89752DF82938A236003FF08E /* PublicKey.swift in Sources */,
+				BB67EE282B54FFEF00573BF0 /* ASINetworkQueue.m in Sources */,
 				9F1FE4D429406E4700E952CA /* CTTabView.m in Sources */,
 				9FDD0F66294AB645000C4DAD /* KMMainViewController.swift in Sources */,
 				BBA8B7A52935CD740097D183 /* KMRemovePasswordAlertWindowController.swift in Sources */,
@@ -16223,6 +16304,7 @@
 				BB8810AB2B4F7D7500AFA63E /* KMVerificationViewController.m in Sources */,
 				BBE78F1D2B36F69F0071AC1A /* KMLeftSideViewController+Note.swift in Sources */,
 				BBCE571A2A72723600508EFC /* NSResponder+KMExtension.swift in Sources */,
+				BB67EE252B54FFEF00573BF0 /* ASIInputStream.m in Sources */,
 				BB146FDA299DC0D100784A6A /* GTLRFramework.m in Sources */,
 				AD85D1A02AEF927D000F4D28 /* KMQucikToolsModel.swift in Sources */,
 				BBC28F432B0EE7D600D73206 /* KMGroupFindTableRowView.swift in Sources */,
@@ -16513,6 +16595,7 @@
 				BBA922242B4E7D340061057A /* HyperLinkButton.swift in Sources */,
 				BBD1F791296FE6A500343885 /* KMPageEditSplitWindowController.swift in Sources */,
 				BB8810A22B4F7D1000AFA63E /* KMVerificationActivateViewController.m in Sources */,
+				BB67EE192B54FFEF00573BF0 /* ASIDataCompressor.m in Sources */,
 				BBE78F212B3875B50071AC1A /* KMLeftSideViewController+Search.swift in Sources */,
 				ADFCEB382B4F78220001EBAF /* KMFile.swift in Sources */,
 				ADD1B6EA2946C02600C3FFF7 /* KMPrintChoosePageSizeMultipageView.swift in Sources */,
@@ -16555,6 +16638,7 @@
 				ADAFDA3B2AE8EEFF00F084BC /* KMAdvertisementRequestServer.swift in Sources */,
 				BBD1F77E296F9BE000343885 /* KMPageEditSettingBaseWindowController.swift in Sources */,
 				9F080B25298FCB0D00FC27DA /* KMDesignToken+Action.swift in Sources */,
+				BB67EE1F2B54FFEF00573BF0 /* ASIFormDataRequest.m in Sources */,
 				ADDF838B2B391A5D00A81A4E /* DSignatureFileListCellView.swift in Sources */,
 				9F81ADC829B9B12C002251F4 /* NSButton+DesignToken.swift in Sources */,
 				BB146FB9299DC0D100784A6A /* GTLRRuntimeCommon.m in Sources */,
@@ -16774,6 +16858,7 @@
 				BBCE57162A72713A00508EFC /* NSViewController+KMExtension.swift in Sources */,
 				BB146FB6299DC0D100784A6A /* GTLRUtilities.m in Sources */,
 				9F8539CD29430BF300DF644E /* KMBrowserWindowController.swift in Sources */,
+				BB67EE1C2B54FFEF00573BF0 /* ASIHTTPRequest.m in Sources */,
 				BB8F4567295AA3ED0037EA22 /* KMHeaderFooterManager.swift in Sources */,
 				9F705F78291A3A84005199AD /* KMHistoryFileDeleteWindowController.swift in Sources */,
 				BB8810872B4F7C2200AFA63E /* KMVerificationAlertViewController.m in Sources */,
@@ -16814,6 +16899,7 @@
 				BB49ED00293F459500C82CA2 /* KMConvertPPTsWindowController.swift in Sources */,
 				BB0542172965705D00F2665C /* KMCropTipView.swift in Sources */,
 				BB89726F294DB67D0045787C /* KMWatermarkAdjectiveBaseView.swift in Sources */,
+				BB67EE222B54FFEF00573BF0 /* ASIDataDecompressor.m in Sources */,
 				BB31981C2AC567B600107371 /* CPDFSelection+PDFListView.swift in Sources */,
 				AD58F4212B1DC29100299EE0 /* KMPrintViewModel.swift in Sources */,
 				AD1CA4132A061CCD0070541F /* KMAnnotationScreenColorViewItem.swift in Sources */,

+ 98 - 0
PDF Office/PDF Master.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -3,4 +3,102 @@
    uuid = "BF64BADD-A23F-49AC-863F-CAF093A6E4D7"
    type = "1"
    version = "2.0">
+   <Breakpoints>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "B76B13E1-8734-4B17-9930-B97EF4578D2C"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/Purchase/DMG/Verification/VerificationManager/VerificationManager.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "392"
+            endingLineNumber = "392"
+            landmarkName = "-verificationWithComplention:"
+            landmarkType = "7">
+            <Locations>
+               <Location
+                  uuid = "B76B13E1-8734-4B17-9930-B97EF4578D2C - bb2cb5473035fa59"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "__51-[VerificationManager verificationWithComplention:]_block_invoke"
+                  moduleName = "PDF Master DMG"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/Purchase/DMG/Verification/VerificationManager/VerificationManager.m"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "396"
+                  endingLineNumber = "396"
+                  offsetFromSymbolStart = "1044">
+               </Location>
+               <Location
+                  uuid = "B76B13E1-8734-4B17-9930-B97EF4578D2C - d8d603426f1e4599"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "__51-[VerificationManager verificationWithComplention:]_block_invoke_3"
+                  moduleName = "PDF Master DMG"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/Purchase/DMG/Verification/VerificationManager/VerificationManager.m"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "392"
+                  endingLineNumber = "392"
+                  offsetFromSymbolStart = "92">
+               </Location>
+            </Locations>
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "5423EA5F-EE41-4612-B7F2-9CB978699CA3"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/Purchase/DMG/Verification/VerificationManager/VerificationManager.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "369"
+            endingLineNumber = "369"
+            landmarkName = "-verificationWithComplention:"
+            landmarkType = "7">
+            <Locations>
+               <Location
+                  uuid = "5423EA5F-EE41-4612-B7F2-9CB978699CA3 - bb2cb5473035ffd4"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "__51-[VerificationManager verificationWithComplention:]_block_invoke"
+                  moduleName = "PDF Master DMG"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/Purchase/DMG/Verification/VerificationManager/VerificationManager.m"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "369"
+                  endingLineNumber = "369"
+                  offsetFromSymbolStart = "280">
+               </Location>
+               <Location
+                  uuid = "5423EA5F-EE41-4612-B7F2-9CB978699CA3 - bb2cb5473035ffd4"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "__51-[VerificationManager verificationWithComplention:]_block_invoke"
+                  moduleName = "PDF Master DMG"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/Documents/Git/PDF_Office/PDF%20Office/PDF%20Master/Class/Purchase/DMG/Verification/VerificationManager/VerificationManager.m"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "369"
+                  endingLineNumber = "369"
+                  offsetFromSymbolStart = "816">
+               </Location>
+            </Locations>
+         </BreakpointContent>
+      </BreakpointProxy>
+   </Breakpoints>
 </Bucket>

+ 2 - 0
PDF Office/PDF Master/AppDelegate.swift

@@ -101,6 +101,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
                                           andEventID: AEEventID(kAEGetURL))
         
         DistributedNotificationCenter.default().addObserver(self, selector: #selector(_themeChanged), name: NSApplication.interfaceThemeChangedNotification, object: nil)
+        
+        VerificationManager.default()
     }
     
     func initiRateData() {

File diff suppressed because it is too large
+ 586 - 596
PDF Office/PDF Master/Class/Purchase/DMG/Verification/VerificationManager/VerificationManager.m


+ 42 - 23
PDF Office/PDF Master/Class/Purchase/IAPProductsManager.m

@@ -15,6 +15,8 @@
 
 #import "VerificationManager.h"
 #import "NSNULL+Filtration.h"
+#import "ASIFormDataRequest.h"
+#import "JSONKit.h"
 
 NSString *const KMStoreLiteKitSecret = @"d8286a8909884e64b84d522305f07463";
 NSString *const KMStoreKitSecret = @"b88b5d687d1547c2ad3c4dd882dec9db";
@@ -415,34 +417,22 @@ NSString * const KMIAPSubscriptionLoadedNotification = @"KMIAPSubscriptionLoaded
     
 #if DEBUG
     NSURL *url = [NSURL URLWithString:KMSandboxServer];
-    NSString *urlString = KMSandboxServer;
 #else
     NSURL *url = [NSURL URLWithString:KMItunesServer];
-    NSString *urlString = KMItunesServer;
 #endif
-    KMRequestServer *server = [KMRequestServer requestServer];
-    [server requestWithUrlString:urlString
-                          method:KMRequestServerMethodTypePost
-                          params:payLoad
-                      completion:^(NSURLSessionDataTask * _Nullable, id _Nullable responseObject, NSError * _Nullable) {
-
-    }];
-    //    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-//        ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
-//        request.defaultResponseEncoding = NSUTF8StringEncoding;
-//        request.timeOutSeconds = 20;
-//        request.numberOfTimesToRetryOnTimeout = 3;
-//        [request setRequestMethod:@"POST"];
-//        [request setRequestHeaders:[NSMutableDictionary dictionaryWithObject:@"application/json" forKey:@"Content-Type"]];
-//        [request setPostBody:[IAPProductsManager mutableDataWithDic:payLoad]];
-//        [request startSynchronous];
-//        NSError *error = request.error;
+//    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
+//    [request setHTTPMethod:@"POST"];
+//    [request setHTTPBody:requestData];
+//
+//    NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
+//    NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
 //        BOOL isSuccessful = NO;
 //        if (!error) {
-//            NSDictionary *jsonResponse = [[request.responseString objectFromJSONString] filterNullObject];
-//            isSuccessful = [self fetchReceipt:jsonResponse[@"data"]];
+//            NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
+//            jsonResponse = [jsonResponse filterNullObject];
+//            isSuccessful = [self fetchReceipt:jsonResponse];
 //            if (isSuccessful) {
-//                [[NSUserDefaults standardUserDefaults] setObject:jsonResponse[@"data"] forKey:KMStoreReceipt];
+//                [[NSUserDefaults standardUserDefaults] setObject:jsonResponse forKey:KMStoreReceipt];
 //                [[NSUserDefaults standardUserDefaults] synchronize];
 //            } else {
 //                error = [[[NSError alloc] init] autorelease];
@@ -453,7 +443,36 @@ NSString * const KMIAPSubscriptionLoadedNotification = @"KMIAPSubscriptionLoaded
 //                handler(error);
 //            }
 //        });
-//    });
+//    }];
+//    [task resume];
+    
+    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        ASIFormDataRequest *request = [[ASIFormDataRequest alloc] initWithURL:url];
+        request.defaultResponseEncoding = NSUTF8StringEncoding;
+        request.timeOutSeconds = 20;
+        request.numberOfTimesToRetryOnTimeout = 3;
+        [request setRequestMethod:@"POST"];
+        [request setRequestHeaders:[NSMutableDictionary dictionaryWithObject:@"application/json" forKey:@"Content-Type"]];
+        [request setPostBody:[IAPProductsManager mutableDataWithDic:payLoad]];
+        [request startSynchronous];
+        NSError *error = request.error;
+        BOOL isSuccessful = NO;
+        if (!error) {
+            NSDictionary *jsonResponse = [[request.responseString objectFromJSONString] filterNullObject];
+            isSuccessful = [self fetchReceipt:jsonResponse[@"data"]];
+            if (isSuccessful) {
+                [[NSUserDefaults standardUserDefaults] setObject:jsonResponse[@"data"] forKey:KMStoreReceipt];
+                [[NSUserDefaults standardUserDefaults] synchronize];
+            } else {
+                error = [[NSError alloc] init];
+            }
+        }
+        dispatch_async(dispatch_get_main_queue(), ^{
+            if (handler) {
+                handler(error);
+            }
+        });
+    });
 }
 
 - (BOOL)fetchReceipt:(NSDictionary *)jsonResponse

+ 103 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASICacheDelegate.h

@@ -0,0 +1,103 @@
+//
+//  ASICacheDelegate.h
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 01/05/2010.
+//  Copyright 2010 All-Seeing Interactive. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+@class ASIHTTPRequest;
+
+// Cache policies control the behaviour of a cache and how requests use the cache
+// When setting a cache policy, you can use a combination of these values as a bitmask
+// For example: [request setCachePolicy:ASIAskServerIfModifiedCachePolicy|ASIFallbackToCacheIfLoadFailsCachePolicy|ASIDoNotWriteToCacheCachePolicy];
+// Note that some of the behaviours below are mutally exclusive - you cannot combine ASIAskServerIfModifiedWhenStaleCachePolicy and ASIAskServerIfModifiedCachePolicy, for example.
+typedef enum _ASICachePolicy {
+
+	// The default cache policy. When you set a request to use this, it will use the cache's defaultCachePolicy
+	// ASIDownloadCache's default cache policy is 'ASIAskServerIfModifiedWhenStaleCachePolicy'
+	ASIUseDefaultCachePolicy = 0,
+
+	// Tell the request not to read from the cache
+	ASIDoNotReadFromCacheCachePolicy = 1,
+
+	// The the request not to write to the cache
+	ASIDoNotWriteToCacheCachePolicy = 2,
+
+	// Ask the server if there is an updated version of this resource (using a conditional GET) ONLY when the cached data is stale
+	ASIAskServerIfModifiedWhenStaleCachePolicy = 4,
+
+	// Always ask the server if there is an updated version of this resource (using a conditional GET)
+	ASIAskServerIfModifiedCachePolicy = 8,
+
+	// If cached data exists, use it even if it is stale. This means requests will not talk to the server unless the resource they are requesting is not in the cache
+	ASIOnlyLoadIfNotCachedCachePolicy = 16,
+
+	// If cached data exists, use it even if it is stale. If cached data does not exist, stop (will not set an error on the request)
+	ASIDontLoadCachePolicy = 32,
+
+	// Specifies that cached data may be used if the request fails. If cached data is used, the request will succeed without error. Usually used in combination with other options above.
+	ASIFallbackToCacheIfLoadFailsCachePolicy = 64
+} ASICachePolicy;
+
+// Cache storage policies control whether cached data persists between application launches (ASICachePermanentlyCacheStoragePolicy) or not (ASICacheForSessionDurationCacheStoragePolicy)
+// Calling [ASIHTTPRequest clearSession] will remove any data stored using ASICacheForSessionDurationCacheStoragePolicy
+typedef enum _ASICacheStoragePolicy {
+	ASICacheForSessionDurationCacheStoragePolicy = 0,
+	ASICachePermanentlyCacheStoragePolicy = 1
+} ASICacheStoragePolicy;
+
+
+@protocol ASICacheDelegate <NSObject>
+
+@required
+
+// Should return the cache policy that will be used when requests have their cache policy set to ASIUseDefaultCachePolicy
+- (ASICachePolicy)defaultCachePolicy;
+
+// Returns the date a cached response should expire on. Pass a non-zero max age to specify a custom date.
+- (NSDate *)expiryDateForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge;
+
+// Updates cached response headers with a new expiry date. Pass a non-zero max age to specify a custom date.
+- (void)updateExpiryForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge;
+
+// Looks at the request's cache policy and any cached headers to determine if the cache data is still valid
+- (BOOL)canUseCachedDataForRequest:(ASIHTTPRequest *)request;
+
+// Removes cached data for a particular request
+- (void)removeCachedDataForRequest:(ASIHTTPRequest *)request;
+
+// Should return YES if the cache considers its cached response current for the request
+// Should return NO is the data is not cached, or (for example) if the cached headers state the request should have expired
+- (BOOL)isCachedDataCurrentForRequest:(ASIHTTPRequest *)request;
+
+// Should store the response for the passed request in the cache
+// When a non-zero maxAge is passed, it should be used as the expiry time for the cached response
+- (void)storeResponseForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge;
+
+// Removes cached data for a particular url
+- (void)removeCachedDataForURL:(NSURL *)url;
+
+// Should return an NSDictionary of cached headers for the passed URL, if it is stored in the cache
+- (NSDictionary *)cachedResponseHeadersForURL:(NSURL *)url;
+
+// Should return the cached body of a response for the passed URL, if it is stored in the cache
+- (NSData *)cachedResponseDataForURL:(NSURL *)url;
+
+// Returns a path to the cached response data, if it exists
+- (NSString *)pathToCachedResponseDataForURL:(NSURL *)url;
+
+// Returns a path to the cached response headers, if they url
+- (NSString *)pathToCachedResponseHeadersForURL:(NSURL *)url;
+
+// Returns the location to use to store cached response headers for a particular request
+- (NSString *)pathToStoreCachedResponseHeadersForRequest:(ASIHTTPRequest *)request;
+
+// Returns the location to use to store a cached response body for a particular request
+- (NSString *)pathToStoreCachedResponseDataForRequest:(ASIHTTPRequest *)request;
+
+// Clear cached data stored for the passed storage policy
+- (void)clearCachedResponsesForStoragePolicy:(ASICacheStoragePolicy)cachePolicy;
+
+@end

+ 42 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIDataCompressor.h

@@ -0,0 +1,42 @@
+//
+//  ASIDataCompressor.h
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 17/08/2010.
+//  Copyright 2010 All-Seeing Interactive. All rights reserved.
+//
+
+// This is a helper class used by ASIHTTPRequest to handle deflating (compressing) data in memory and on disk
+// You may also find it helpful if you need to deflate data and files yourself - see the class methods below
+// Most of the zlib stuff is based on the sample code by Mark Adler available at http://zlib.net
+
+#import <Foundation/Foundation.h>
+#import <zlib.h>
+
+@interface ASIDataCompressor : NSObject {
+	BOOL streamReady;
+	z_stream zStream;
+}
+
+// Convenience constructor will call setupStream for you
++ (id)compressor;
+
+// Compress the passed chunk of data
+// Passing YES for shouldFinish will finalize the deflated data - you must pass YES when you are on the last chunk of data
+- (NSData *)compressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err shouldFinish:(BOOL)shouldFinish;
+
+// Convenience method - pass it some data, and you'll get deflated data back
++ (NSData *)compressData:(NSData*)uncompressedData error:(NSError **)err;
+
+// Convenience method - pass it a file containing the data to compress in sourcePath, and it will write deflated data to destinationPath
++ (BOOL)compressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err;
+
+// Sets up zlib to handle the inflating. You only need to call this yourself if you aren't using the convenience constructor 'compressor'
+- (NSError *)setupStream;
+
+// Tells zlib to clean up. You need to call this if you need to cancel deflating part way through
+// If deflating finishes or fails, this method will be called automatically
+- (NSError *)closeStream;
+
+@property (atomic, assign, readonly) BOOL streamReady;
+@end

+ 219 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIDataCompressor.m

@@ -0,0 +1,219 @@
+//
+//  ASIDataCompressor.m
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 17/08/2010.
+//  Copyright 2010 All-Seeing Interactive. All rights reserved.
+//
+
+#import "ASIDataCompressor.h"
+#import "ASIHTTPRequest.h"
+
+#define DATA_CHUNK_SIZE 262144 // Deal with gzipped data in 256KB chunks
+#define COMPRESSION_AMOUNT Z_DEFAULT_COMPRESSION
+
+@interface ASIDataCompressor ()
++ (NSError *)deflateErrorWithCode:(int)code;
+@end
+
+@implementation ASIDataCompressor
+
++ (id)compressor
+{
+	ASIDataCompressor *compressor = [[[self alloc] init] autorelease];
+	[compressor setupStream];
+	return compressor;
+}
+
+- (void)dealloc
+{
+	if (streamReady) {
+		[self closeStream];
+	}
+	[super dealloc];
+}
+
+- (NSError *)setupStream
+{
+	if (streamReady) {
+		return nil;
+	}
+	// Setup the inflate stream
+	zStream.zalloc = Z_NULL;
+	zStream.zfree = Z_NULL;
+	zStream.opaque = Z_NULL;
+	zStream.avail_in = 0;
+	zStream.next_in = 0;
+	int status = deflateInit2(&zStream, COMPRESSION_AMOUNT, Z_DEFLATED, (15+16), 8, Z_DEFAULT_STRATEGY);
+	if (status != Z_OK) {
+		return [[self class] deflateErrorWithCode:status];
+	}
+	streamReady = YES;
+	return nil;
+}
+
+- (NSError *)closeStream
+{
+	if (!streamReady) {
+		return nil;
+	}
+	// Close the deflate stream
+	streamReady = NO;
+	int status = deflateEnd(&zStream);
+	if (status != Z_OK) {
+		return [[self class] deflateErrorWithCode:status];
+	}
+	return nil;
+}
+
+- (NSData *)compressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err shouldFinish:(BOOL)shouldFinish
+{
+	if (length == 0) return nil;
+	
+	NSUInteger halfLength = length/2;
+	
+	// We'll take a guess that the compressed data will fit in half the size of the original (ie the max to compress at once is half DATA_CHUNK_SIZE), if not, we'll increase it below
+	NSMutableData *outputData = [NSMutableData dataWithLength:length/2]; 
+	
+	int status;
+	
+	zStream.next_in = bytes;
+	zStream.avail_in = (unsigned int)length;
+	zStream.avail_out = 0;
+
+	NSUInteger bytesProcessedAlready = zStream.total_out;
+	while (zStream.avail_out == 0) {
+		
+		if (zStream.total_out-bytesProcessedAlready >= [outputData length]) {
+			[outputData increaseLengthBy:halfLength];
+		}
+		
+		zStream.next_out = (Bytef*)[outputData mutableBytes] + zStream.total_out-bytesProcessedAlready;
+		zStream.avail_out = (unsigned int)([outputData length] - (zStream.total_out-bytesProcessedAlready));
+		status = deflate(&zStream, shouldFinish ? Z_FINISH : Z_NO_FLUSH);
+		
+		if (status == Z_STREAM_END) {
+			break;
+		} else if (status != Z_OK) {
+			if (err) {
+				*err = [[self class] deflateErrorWithCode:status];
+			}
+			return NO;
+		}
+	}
+
+	// Set real length
+	[outputData setLength: zStream.total_out-bytesProcessedAlready];
+	return outputData;
+}
+
+
++ (NSData *)compressData:(NSData*)uncompressedData error:(NSError **)err
+{
+	NSError *theError = nil;
+	NSData *outputData = [[ASIDataCompressor compressor] compressBytes:(Bytef *)[uncompressedData bytes] length:[uncompressedData length] error:&theError shouldFinish:YES];
+	if (theError) {
+		if (err) {
+			*err = theError;
+		}
+		return nil;
+	}
+	return outputData;
+}
+
+
+
++ (BOOL)compressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err
+{
+	NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease];
+
+	// Create an empty file at the destination path
+	if (![fileManager createFileAtPath:destinationPath contents:[NSData data] attributes:nil]) {
+		if (err) {
+			*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed because we were to create a file at %@",sourcePath,destinationPath],NSLocalizedDescriptionKey,nil]];
+		}
+		return NO;
+	}
+	
+	// Ensure the source file exists
+	if (![fileManager fileExistsAtPath:sourcePath]) {
+		if (err) {
+			*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed the file does not exist",sourcePath],NSLocalizedDescriptionKey,nil]];
+		}
+		return NO;
+	}
+	
+	UInt8 inputData[DATA_CHUNK_SIZE];
+	NSData *outputData;
+	NSInteger readLength;
+	NSError *theError = nil;
+	
+	ASIDataCompressor *compressor = [ASIDataCompressor compressor];
+	
+	NSInputStream *inputStream = [NSInputStream inputStreamWithFileAtPath:sourcePath];
+	[inputStream open];
+	NSOutputStream *outputStream = [NSOutputStream outputStreamToFileAtPath:destinationPath append:NO];
+	[outputStream open];
+	
+    while ([compressor streamReady]) {
+		
+		// Read some data from the file
+		readLength = [inputStream read:inputData maxLength:DATA_CHUNK_SIZE];
+
+		// Make sure nothing went wrong
+		if ([inputStream streamStatus] == NSStreamStatusError) {
+			if (err) {
+				*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed because we were unable to read from the source data file",sourcePath],NSLocalizedDescriptionKey,[inputStream streamError],NSUnderlyingErrorKey,nil]];
+			}
+			[compressor closeStream];
+			return NO;
+		}
+		// Have we reached the end of the input data?
+		if (!readLength) {
+			break;
+		}
+		
+		// Attempt to deflate the chunk of data
+		outputData = [compressor compressBytes:inputData length:(NSUInteger)readLength error:&theError shouldFinish:readLength < DATA_CHUNK_SIZE];
+		if (theError) {
+			if (err) {
+				*err = theError;
+			}
+			[compressor closeStream];
+			return NO;
+		}
+		
+		// Write the deflated data out to the destination file
+		[outputStream write:(const uint8_t *)[outputData bytes] maxLength:[outputData length]];
+		
+		// Make sure nothing went wrong
+		if ([inputStream streamStatus] == NSStreamStatusError) {
+			if (err) {
+				*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of %@ failed because we were unable to write to the destination data file at %@",sourcePath,destinationPath],NSLocalizedDescriptionKey,[outputStream streamError],NSUnderlyingErrorKey,nil]];
+            }
+			[compressor closeStream];
+			return NO;
+		}
+		
+    }
+	[inputStream close];
+	[outputStream close];
+
+	NSError *error = [compressor closeStream];
+	if (error) {
+		if (err) {
+			*err = error;
+		}
+		return NO;
+	}
+
+	return YES;
+}
+
++ (NSError *)deflateErrorWithCode:(int)code
+{
+	return [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Compression of data failed with code %d",code],NSLocalizedDescriptionKey,nil]];
+}
+
+@synthesize streamReady;
+@end

+ 41 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIDataDecompressor.h

@@ -0,0 +1,41 @@
+//
+//  ASIDataDecompressor.h
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 17/08/2010.
+//  Copyright 2010 All-Seeing Interactive. All rights reserved.
+//
+
+// This is a helper class used by ASIHTTPRequest to handle inflating (decompressing) data in memory and on disk
+// You may also find it helpful if you need to inflate data and files yourself - see the class methods below
+// Most of the zlib stuff is based on the sample code by Mark Adler available at http://zlib.net
+
+#import <Foundation/Foundation.h>
+#import <zlib.h>
+
+@interface ASIDataDecompressor : NSObject {
+	BOOL streamReady;
+	z_stream zStream;
+}
+
+// Convenience constructor will call setupStream for you
++ (id)decompressor;
+
+// Uncompress the passed chunk of data
+- (NSData *)uncompressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err;
+
+// Convenience method - pass it some deflated data, and you'll get inflated data back
++ (NSData *)uncompressData:(NSData*)compressedData error:(NSError **)err;
+
+// Convenience method - pass it a file containing deflated data in sourcePath, and it will write inflated data to destinationPath
++ (BOOL)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err;
+
+// Sets up zlib to handle the inflating. You only need to call this yourself if you aren't using the convenience constructor 'decompressor'
+- (NSError *)setupStream;
+
+// Tells zlib to clean up. You need to call this if you need to cancel inflating part way through
+// If inflating finishes or fails, this method will be called automatically
+- (NSError *)closeStream;
+
+@property (atomic, assign, readonly) BOOL streamReady;
+@end

+ 218 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIDataDecompressor.m

@@ -0,0 +1,218 @@
+//
+//  ASIDataDecompressor.m
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 17/08/2010.
+//  Copyright 2010 All-Seeing Interactive. All rights reserved.
+//
+
+#import "ASIDataDecompressor.h"
+#import "ASIHTTPRequest.h"
+
+#define DATA_CHUNK_SIZE 262144 // Deal with gzipped data in 256KB chunks
+
+@interface ASIDataDecompressor ()
++ (NSError *)inflateErrorWithCode:(int)code;
+@end;
+
+@implementation ASIDataDecompressor
+
++ (id)decompressor
+{
+	ASIDataDecompressor *decompressor = [[[self alloc] init] autorelease];
+	[decompressor setupStream];
+	return decompressor;
+}
+
+- (void)dealloc
+{
+	if (streamReady) {
+		[self closeStream];
+	}
+	[super dealloc];
+}
+
+- (NSError *)setupStream
+{
+	if (streamReady) {
+		return nil;
+	}
+	// Setup the inflate stream
+	zStream.zalloc = Z_NULL;
+	zStream.zfree = Z_NULL;
+	zStream.opaque = Z_NULL;
+	zStream.avail_in = 0;
+	zStream.next_in = 0;
+	int status = inflateInit2(&zStream, (15+32));
+	if (status != Z_OK) {
+		return [[self class] inflateErrorWithCode:status];
+	}
+	streamReady = YES;
+	return nil;
+}
+
+- (NSError *)closeStream
+{
+	if (!streamReady) {
+		return nil;
+	}
+	// Close the inflate stream
+	streamReady = NO;
+	int status = inflateEnd(&zStream);
+	if (status != Z_OK) {
+		return [[self class] inflateErrorWithCode:status];
+	}
+	return nil;
+}
+
+- (NSData *)uncompressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err
+{
+	if (length == 0) return nil;
+	
+	NSUInteger halfLength = length/2;
+	NSMutableData *outputData = [NSMutableData dataWithLength:length+halfLength];
+
+	int status;
+	
+	zStream.next_in = bytes;
+	zStream.avail_in = (unsigned int)length;
+	zStream.avail_out = 0;
+	
+	NSUInteger bytesProcessedAlready = zStream.total_out;
+	while (zStream.avail_in != 0) {
+		
+		if (zStream.total_out-bytesProcessedAlready >= [outputData length]) {
+			[outputData increaseLengthBy:halfLength];
+		}
+		
+		zStream.next_out = (Bytef*)[outputData mutableBytes] + zStream.total_out-bytesProcessedAlready;
+		zStream.avail_out = (unsigned int)([outputData length] - (zStream.total_out-bytesProcessedAlready));
+		
+		status = inflate(&zStream, Z_NO_FLUSH);
+		
+		if (status == Z_STREAM_END) {
+			break;
+		} else if (status != Z_OK) {
+			if (err) {
+				*err = [[self class] inflateErrorWithCode:status];
+			}
+			return nil;
+		}
+	}
+	
+	// Set real length
+	[outputData setLength: zStream.total_out-bytesProcessedAlready];
+	return outputData;
+}
+
+
++ (NSData *)uncompressData:(NSData*)compressedData error:(NSError **)err
+{
+	NSError *theError = nil;
+	NSData *outputData = [[ASIDataDecompressor decompressor] uncompressBytes:(Bytef *)[compressedData bytes] length:[compressedData length] error:&theError];
+	if (theError) {
+		if (err) {
+			*err = theError;
+		}
+		return nil;
+	}
+	return outputData;
+}
+
++ (BOOL)uncompressDataFromFile:(NSString *)sourcePath toFile:(NSString *)destinationPath error:(NSError **)err
+{
+	NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease];
+
+	// Create an empty file at the destination path
+	if (![fileManager createFileAtPath:destinationPath contents:[NSData data] attributes:nil]) {
+		if (err) {
+			*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed because we were to create a file at %@",sourcePath,destinationPath],NSLocalizedDescriptionKey,nil]];
+		}
+		return NO;
+	}
+	
+	// Ensure the source file exists
+	if (![fileManager fileExistsAtPath:sourcePath]) {
+		if (err) {
+			*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed the file does not exist",sourcePath],NSLocalizedDescriptionKey,nil]];
+		}
+		return NO;
+	}
+	
+	UInt8 inputData[DATA_CHUNK_SIZE];
+	NSData *outputData;
+	NSInteger readLength;
+	NSError *theError = nil;
+	
+
+	ASIDataDecompressor *decompressor = [ASIDataDecompressor decompressor];
+
+	NSInputStream *inputStream = [NSInputStream inputStreamWithFileAtPath:sourcePath];
+	[inputStream open];
+	NSOutputStream *outputStream = [NSOutputStream outputStreamToFileAtPath:destinationPath append:NO];
+	[outputStream open];
+	
+    while ([decompressor streamReady]) {
+		
+		// Read some data from the file
+		readLength = [inputStream read:inputData maxLength:DATA_CHUNK_SIZE];
+		
+		// Make sure nothing went wrong
+		if ([inputStream streamStatus] == NSStreamStatusError) {
+			if (err) {
+				*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed because we were unable to read from the source data file",sourcePath],NSLocalizedDescriptionKey,[inputStream streamError],NSUnderlyingErrorKey,nil]];
+			}
+            [decompressor closeStream];
+			return NO;
+		}
+		// Have we reached the end of the input data?
+		if (!readLength) {
+			break;
+		}
+
+		// Attempt to inflate the chunk of data
+		outputData = [decompressor uncompressBytes:inputData length:(NSUInteger)readLength error:&theError];
+		if (theError) {
+			if (err) {
+				*err = theError;
+			}
+			[decompressor closeStream];
+			return NO;
+		}
+		
+		// Write the inflated data out to the destination file
+		[outputStream write:(Bytef*)[outputData bytes] maxLength:[outputData length]];
+		
+		// Make sure nothing went wrong
+		if ([inputStream streamStatus] == NSStreamStatusError) {
+			if (err) {
+				*err = [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of %@ failed because we were unable to write to the destination data file at %@",sourcePath,destinationPath],NSLocalizedDescriptionKey,[outputStream streamError],NSUnderlyingErrorKey,nil]];
+            }
+			[decompressor closeStream];
+			return NO;
+		}
+		
+    }
+	
+	[inputStream close];
+	[outputStream close];
+
+	NSError *error = [decompressor closeStream];
+	if (error) {
+		if (err) {
+			*err = error;
+		}
+		return NO;
+	}
+
+	return YES;
+}
+
+
++ (NSError *)inflateErrorWithCode:(int)code
+{
+	return [NSError errorWithDomain:NetworkRequestErrorDomain code:ASICompressionError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"Decompression of data failed with code %d",code],NSLocalizedDescriptionKey,nil]];
+}
+
+@synthesize streamReady;
+@end

+ 46 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIDownloadCache.h

@@ -0,0 +1,46 @@
+//
+//  ASIDownloadCache.h
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 01/05/2010.
+//  Copyright 2010 All-Seeing Interactive. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "ASICacheDelegate.h"
+
+@interface ASIDownloadCache : NSObject <ASICacheDelegate> {
+	
+	// The default cache policy for this cache
+	// Requests that store data in the cache will use this cache policy if their cache policy is set to ASIUseDefaultCachePolicy
+	// Defaults to ASIAskServerIfModifiedWhenStaleCachePolicy
+	ASICachePolicy defaultCachePolicy;
+	
+	// The directory in which cached data will be stored
+	// Defaults to a directory called 'ASIHTTPRequestCache' in the temporary directory
+	NSString *storagePath;
+	
+	// Mediates access to the cache
+	NSRecursiveLock *accessLock;
+	
+	// When YES, the cache will look for cache-control / pragma: no-cache headers, and won't reuse store responses if it finds them
+	BOOL shouldRespectCacheControlHeaders;
+}
+
+// Returns a static instance of an ASIDownloadCache
+// In most circumstances, it will make sense to use this as a global cache, rather than creating your own cache
+// To make ASIHTTPRequests use it automatically, use [ASIHTTPRequest setDefaultCache:[ASIDownloadCache sharedCache]];
++ (id)sharedCache;
+
+// A helper function that determines if the server has requested data should not be cached by looking at the request's response headers
++ (BOOL)serverAllowsResponseCachingForRequest:(ASIHTTPRequest *)request;
+
+// A list of file extensions that we know won't be readable by a webview when accessed locally
+// If we're asking for a path to cache a particular url and it has one of these extensions, we change it to '.html'
++ (NSArray *)fileExtensionsToHandleAsHTML;
+
+@property (assign, nonatomic) ASICachePolicy defaultCachePolicy;
+@property (retain, nonatomic) NSString *storagePath;
+@property (atomic, retain) NSRecursiveLock *accessLock;
+@property (atomic, assign) BOOL shouldRespectCacheControlHeaders;
+@end

+ 514 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIDownloadCache.m

@@ -0,0 +1,514 @@
+//
+//  ASIDownloadCache.m
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 01/05/2010.
+//  Copyright 2010 All-Seeing Interactive. All rights reserved.
+//
+
+#import "ASIDownloadCache.h"
+#import "ASIHTTPRequest.h"
+#import <CommonCrypto/CommonHMAC.h>
+
+static ASIDownloadCache *sharedCache = nil;
+
+static NSString *sessionCacheFolder = @"SessionStore";
+static NSString *permanentCacheFolder = @"PermanentStore";
+static NSArray *fileExtensionsToHandleAsHTML = nil;
+
+@interface ASIDownloadCache ()
++ (NSString *)keyForURL:(NSURL *)url;
+- (NSString *)pathToFile:(NSString *)file;
+@end
+
+@implementation ASIDownloadCache
+
++ (void)initialize
+{
+	if (self == [ASIDownloadCache class]) {
+		// Obviously this is not an exhaustive list, but hopefully these are the most commonly used and this will 'just work' for the widest range of people
+		// I imagine many web developers probably use url rewriting anyway
+		fileExtensionsToHandleAsHTML = [[NSArray alloc] initWithObjects:@"asp",@"aspx",@"jsp",@"php",@"rb",@"py",@"pl",@"cgi", nil];
+	}
+}
+
+- (id)init
+{
+	self = [super init];
+	[self setShouldRespectCacheControlHeaders:YES];
+	[self setDefaultCachePolicy:ASIUseDefaultCachePolicy];
+	[self setAccessLock:[[[NSRecursiveLock alloc] init] autorelease]];
+	return self;
+}
+
++ (id)sharedCache
+{
+	if (!sharedCache) {
+		@synchronized(self) {
+			if (!sharedCache) {
+				sharedCache = [[self alloc] init];
+				[sharedCache setStoragePath:[[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"ASIHTTPRequestCache"]];
+			}
+		}
+	}
+	return sharedCache;
+}
+
+- (void)dealloc
+{
+	[storagePath release];
+	[accessLock release];
+	[super dealloc];
+}
+
+- (NSString *)storagePath
+{
+	[[self accessLock] lock];
+	NSString *p = [[storagePath retain] autorelease];
+	[[self accessLock] unlock];
+	return p;
+}
+
+
+- (void)setStoragePath:(NSString *)path
+{
+	[[self accessLock] lock];
+	[self clearCachedResponsesForStoragePolicy:ASICacheForSessionDurationCacheStoragePolicy];
+	[storagePath release];
+	storagePath = [path retain];
+
+	NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease];
+
+	BOOL isDirectory = NO;
+	NSArray *directories = [NSArray arrayWithObjects:path,[path stringByAppendingPathComponent:sessionCacheFolder],[path stringByAppendingPathComponent:permanentCacheFolder],nil];
+	for (NSString *directory in directories) {
+		BOOL exists = [fileManager fileExistsAtPath:directory isDirectory:&isDirectory];
+		if (exists && !isDirectory) {
+			[[self accessLock] unlock];
+			[NSException raise:@"FileExistsAtCachePath" format:@"Cannot create a directory for the cache at '%@', because a file already exists",directory];
+		} else if (!exists) {
+			[fileManager createDirectoryAtPath:directory withIntermediateDirectories:NO attributes:nil error:nil];
+			if (![fileManager fileExistsAtPath:directory]) {
+				[[self accessLock] unlock];
+				[NSException raise:@"FailedToCreateCacheDirectory" format:@"Failed to create a directory for the cache at '%@'",directory];
+			}
+		}
+	}
+	[self clearCachedResponsesForStoragePolicy:ASICacheForSessionDurationCacheStoragePolicy];
+	[[self accessLock] unlock];
+}
+
+- (void)updateExpiryForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge
+{
+	NSString *headerPath = [self pathToStoreCachedResponseHeadersForRequest:request];
+	NSMutableDictionary *cachedHeaders = [NSMutableDictionary dictionaryWithContentsOfFile:headerPath];
+	if (!cachedHeaders) {
+		return;
+	}
+	NSDate *expires = [self expiryDateForRequest:request maxAge:maxAge];
+	if (!expires) {
+		return;
+	}
+	[cachedHeaders setObject:[NSNumber numberWithDouble:[expires timeIntervalSince1970]] forKey:@"X-ASIHTTPRequest-Expires"];
+	[cachedHeaders writeToFile:headerPath atomically:NO];
+}
+
+- (NSDate *)expiryDateForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge
+{
+  return [ASIHTTPRequest expiryDateForRequest:request maxAge:maxAge];
+}
+
+- (void)storeResponseForRequest:(ASIHTTPRequest *)request maxAge:(NSTimeInterval)maxAge
+{
+	[[self accessLock] lock];
+
+	if ([request error] || ![request responseHeaders] || ([request cachePolicy] & ASIDoNotWriteToCacheCachePolicy)) {
+		[[self accessLock] unlock];
+		return;
+	}
+
+	// We only cache 200/OK or redirect reponses (redirect responses are cached so the cache works better with no internet connection)
+	int responseCode = [request responseStatusCode];
+	if (responseCode != 200 && responseCode != 301 && responseCode != 302 && responseCode != 303 && responseCode != 307) {
+		[[self accessLock] unlock];
+		return;
+	}
+
+	if ([self shouldRespectCacheControlHeaders] && ![[self class] serverAllowsResponseCachingForRequest:request]) {
+		[[self accessLock] unlock];
+		return;
+	}
+
+	NSString *headerPath = [self pathToStoreCachedResponseHeadersForRequest:request];
+	NSString *dataPath = [self pathToStoreCachedResponseDataForRequest:request];
+
+	NSMutableDictionary *responseHeaders = [NSMutableDictionary dictionaryWithDictionary:[request responseHeaders]];
+	if ([request isResponseCompressed]) {
+		[responseHeaders removeObjectForKey:@"Content-Encoding"];
+	}
+
+	// Create a special 'X-ASIHTTPRequest-Expires' header
+	// This is what we use for deciding if cached data is current, rather than parsing the expires / max-age headers individually each time
+	// We store this as a timestamp to make reading it easier as NSDateFormatter is quite expensive
+
+	NSDate *expires = [self expiryDateForRequest:request maxAge:maxAge];
+	if (expires) {
+		[responseHeaders setObject:[NSNumber numberWithDouble:[expires timeIntervalSince1970]] forKey:@"X-ASIHTTPRequest-Expires"];
+	}
+
+	// Store the response code in a custom header so we can reuse it later
+
+	// We'll change 304/Not Modified to 200/OK because this is likely to be us updating the cached headers with a conditional GET
+	int statusCode = [request responseStatusCode];
+	if (statusCode == 304) {
+		statusCode = 200;
+	}
+	[responseHeaders setObject:[NSNumber numberWithInt:statusCode] forKey:@"X-ASIHTTPRequest-Response-Status-Code"];
+
+	[responseHeaders writeToFile:headerPath atomically:NO];
+
+	if ([request responseData]) {
+		[[request responseData] writeToFile:dataPath atomically:NO];
+	} else if ([request downloadDestinationPath] && ![[request downloadDestinationPath] isEqualToString:dataPath]) {        
+		NSError *error = nil;
+        NSFileManager* manager = [[NSFileManager alloc] init];
+        if ([manager fileExistsAtPath:dataPath]) {
+            [manager removeItemAtPath:dataPath error:&error];
+        }
+        [manager copyItemAtPath:[request downloadDestinationPath] toPath:dataPath error:&error];
+        [manager release];
+	}
+	[[self accessLock] unlock];
+}
+
+- (NSDictionary *)cachedResponseHeadersForURL:(NSURL *)url
+{
+	NSString *path = [self pathToCachedResponseHeadersForURL:url];
+	if (path) {
+		return [NSDictionary dictionaryWithContentsOfFile:path];
+	}
+	return nil;
+}
+
+- (NSData *)cachedResponseDataForURL:(NSURL *)url
+{
+	NSString *path = [self pathToCachedResponseDataForURL:url];
+	if (path) {
+		return [NSData dataWithContentsOfFile:path];
+	}
+	return nil;
+}
+
+- (NSString *)pathToCachedResponseDataForURL:(NSURL *)url
+{
+	// Grab the file extension, if there is one. We do this so we can save the cached response with the same file extension - this is important if you want to display locally cached data in a web view 
+	NSString *extension = [[url path] pathExtension];
+
+	// If the url doesn't have an extension, we'll add one so a webview can read it when locally cached
+	// If the url has the extension of a common web scripting language, we'll change the extension on the cached path to html for the same reason
+	if (![extension length] || [[[self class] fileExtensionsToHandleAsHTML] containsObject:[extension lowercaseString]]) {
+		extension = @"html";
+	}
+	return [self pathToFile:[[[self class] keyForURL:url] stringByAppendingPathExtension:extension]];
+}
+
++ (NSArray *)fileExtensionsToHandleAsHTML
+{
+	return fileExtensionsToHandleAsHTML;
+}
+
+
+- (NSString *)pathToCachedResponseHeadersForURL:(NSURL *)url
+{
+	return [self pathToFile:[[[self class] keyForURL:url] stringByAppendingPathExtension:@"cachedheaders"]];
+}
+
+- (NSString *)pathToFile:(NSString *)file
+{
+	[[self accessLock] lock];
+	if (![self storagePath]) {
+		[[self accessLock] unlock];
+		return nil;
+	}
+
+	NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease];
+
+	// Look in the session store
+	NSString *dataPath = [[[self storagePath] stringByAppendingPathComponent:sessionCacheFolder] stringByAppendingPathComponent:file];
+	if ([fileManager fileExistsAtPath:dataPath]) {
+		[[self accessLock] unlock];
+		return dataPath;
+	}
+	// Look in the permanent store
+	dataPath = [[[self storagePath] stringByAppendingPathComponent:permanentCacheFolder] stringByAppendingPathComponent:file];
+	if ([fileManager fileExistsAtPath:dataPath]) {
+		[[self accessLock] unlock];
+		return dataPath;
+	}
+	[[self accessLock] unlock];
+	return nil;
+}
+
+
+- (NSString *)pathToStoreCachedResponseDataForRequest:(ASIHTTPRequest *)request
+{
+	[[self accessLock] lock];
+	if (![self storagePath]) {
+		[[self accessLock] unlock];
+		return nil;
+	}
+
+	NSString *path = [[self storagePath] stringByAppendingPathComponent:([request cacheStoragePolicy] == ASICacheForSessionDurationCacheStoragePolicy ? sessionCacheFolder : permanentCacheFolder)];
+
+	// Grab the file extension, if there is one. We do this so we can save the cached response with the same file extension - this is important if you want to display locally cached data in a web view 
+	NSString *extension = [[[request url] path] pathExtension];
+
+	// If the url doesn't have an extension, we'll add one so a webview can read it when locally cached
+	// If the url has the extension of a common web scripting language, we'll change the extension on the cached path to html for the same reason
+	if (![extension length] || [[[self class] fileExtensionsToHandleAsHTML] containsObject:[extension lowercaseString]]) {
+		extension = @"html";
+	}
+	path =  [path stringByAppendingPathComponent:[[[self class] keyForURL:[request url]] stringByAppendingPathExtension:extension]];
+	[[self accessLock] unlock];
+	return path;
+}
+
+- (NSString *)pathToStoreCachedResponseHeadersForRequest:(ASIHTTPRequest *)request
+{
+	[[self accessLock] lock];
+	if (![self storagePath]) {
+		[[self accessLock] unlock];
+		return nil;
+	}
+	NSString *path = [[self storagePath] stringByAppendingPathComponent:([request cacheStoragePolicy] == ASICacheForSessionDurationCacheStoragePolicy ? sessionCacheFolder : permanentCacheFolder)];
+	path =  [path stringByAppendingPathComponent:[[[self class] keyForURL:[request url]] stringByAppendingPathExtension:@"cachedheaders"]];
+	[[self accessLock] unlock];
+	return path;
+}
+
+- (void)removeCachedDataForURL:(NSURL *)url
+{
+	[[self accessLock] lock];
+	if (![self storagePath]) {
+		[[self accessLock] unlock];
+		return;
+	}
+	NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease];
+
+	NSString *path = [self pathToCachedResponseHeadersForURL:url];
+	if (path) {
+		[fileManager removeItemAtPath:path error:NULL];
+	}
+
+	path = [self pathToCachedResponseDataForURL:url];
+	if (path) {
+		[fileManager removeItemAtPath:path error:NULL];
+	}
+	[[self accessLock] unlock];
+}
+
+- (void)removeCachedDataForRequest:(ASIHTTPRequest *)request
+{
+	[self removeCachedDataForURL:[request url]];
+}
+
+- (BOOL)isCachedDataCurrentForRequest:(ASIHTTPRequest *)request
+{
+	[[self accessLock] lock];
+	if (![self storagePath]) {
+		[[self accessLock] unlock];
+		return NO;
+	}
+	NSDictionary *cachedHeaders = [self cachedResponseHeadersForURL:[request url]];
+	if (!cachedHeaders) {
+		[[self accessLock] unlock];
+		return NO;
+	}
+	NSString *dataPath = [self pathToCachedResponseDataForURL:[request url]];
+	if (!dataPath) {
+		[[self accessLock] unlock];
+		return NO;
+	}
+
+	// New content is not different
+	if ([request responseStatusCode] == 304) {
+		[[self accessLock] unlock];
+		return YES;
+	}
+
+	// If we already have response headers for this request, check to see if the new content is different
+	// We check [request complete] so that we don't end up comparing response headers from a redirection with these
+	if ([request responseHeaders] && [request complete]) {
+
+		// If the Etag or Last-Modified date are different from the one we have, we'll have to fetch this resource again
+		NSArray *headersToCompare = [NSArray arrayWithObjects:@"Etag",@"Last-Modified",nil];
+		for (NSString *header in headersToCompare) {
+			if (![[[request responseHeaders] objectForKey:header] isEqualToString:[cachedHeaders objectForKey:header]]) {
+				[[self accessLock] unlock];
+				return NO;
+			}
+		}
+	}
+
+	if ([self shouldRespectCacheControlHeaders]) {
+
+		// Look for X-ASIHTTPRequest-Expires header to see if the content is out of date
+		NSNumber *expires = [cachedHeaders objectForKey:@"X-ASIHTTPRequest-Expires"];
+		if (expires) {
+			if ([[NSDate dateWithTimeIntervalSince1970:[expires doubleValue]] timeIntervalSinceNow] >= 0) {
+				[[self accessLock] unlock];
+				return YES;
+			}
+		}
+
+		// No explicit expiration time sent by the server
+		[[self accessLock] unlock];
+		return NO;
+	}
+	
+
+	[[self accessLock] unlock];
+	return YES;
+}
+
+- (ASICachePolicy)defaultCachePolicy
+{
+	[[self accessLock] lock];
+	ASICachePolicy cp = defaultCachePolicy;
+	[[self accessLock] unlock];
+	return cp;
+}
+
+
+- (void)setDefaultCachePolicy:(ASICachePolicy)cachePolicy
+{
+	[[self accessLock] lock];
+	if (!cachePolicy) {
+		defaultCachePolicy = ASIAskServerIfModifiedWhenStaleCachePolicy;
+	}  else {
+		defaultCachePolicy = cachePolicy;	
+	}
+	[[self accessLock] unlock];
+}
+
+- (void)clearCachedResponsesForStoragePolicy:(ASICacheStoragePolicy)storagePolicy
+{
+	[[self accessLock] lock];
+	if (![self storagePath]) {
+		[[self accessLock] unlock];
+		return;
+	}
+	NSString *path = [[self storagePath] stringByAppendingPathComponent:(storagePolicy == ASICacheForSessionDurationCacheStoragePolicy ? sessionCacheFolder : permanentCacheFolder)];
+
+	NSFileManager *fileManager = [[[NSFileManager alloc] init] autorelease];
+
+	BOOL isDirectory = NO;
+	BOOL exists = [fileManager fileExistsAtPath:path isDirectory:&isDirectory];
+	if (!exists || !isDirectory) {
+		[[self accessLock] unlock];
+		return;
+	}
+	NSError *error = nil;
+	NSArray *cacheFiles = [fileManager contentsOfDirectoryAtPath:path error:&error];
+	if (error) {
+		[[self accessLock] unlock];
+		[NSException raise:@"FailedToTraverseCacheDirectory" format:@"Listing cache directory failed at path '%@'",path];	
+	}
+	for (NSString *file in cacheFiles) {
+		[fileManager removeItemAtPath:[path stringByAppendingPathComponent:file] error:&error];
+		if (error) {
+			[[self accessLock] unlock];
+			[NSException raise:@"FailedToRemoveCacheFile" format:@"Failed to remove cached data at path '%@'",path];
+		}
+	}
+	[[self accessLock] unlock];
+}
+
++ (BOOL)serverAllowsResponseCachingForRequest:(ASIHTTPRequest *)request
+{
+	NSString *cacheControl = [[[request responseHeaders] objectForKey:@"Cache-Control"] lowercaseString];
+	if (cacheControl) {
+		if ([cacheControl isEqualToString:@"no-cache"] || [cacheControl isEqualToString:@"no-store"]) {
+			return NO;
+		}
+	}
+	NSString *pragma = [[[request responseHeaders] objectForKey:@"Pragma"] lowercaseString];
+	if (pragma) {
+		if ([pragma isEqualToString:@"no-cache"]) {
+			return NO;
+		}
+	}
+	return YES;
+}
+
++ (NSString *)keyForURL:(NSURL *)url
+{
+	NSString *urlString = [url absoluteString];
+	if ([urlString length] == 0) {
+		return nil;
+	}
+
+	// Strip trailing slashes so http://allseeing-i.com/ASIHTTPRequest/ is cached the same as http://allseeing-i.com/ASIHTTPRequest
+	if ([[urlString substringFromIndex:[urlString length]-1] isEqualToString:@"/"]) {
+		urlString = [urlString substringToIndex:[urlString length]-1];
+	}
+
+	// Borrowed from: http://stackoverflow.com/questions/652300/using-md5-hash-on-a-string-in-cocoa
+	const char *cStr = [urlString UTF8String];
+	unsigned char result[16];
+	CC_MD5(cStr, (CC_LONG)strlen(cStr), result);
+	return [NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7],result[8], result[9], result[10], result[11],result[12], result[13], result[14], result[15]]; 	
+}
+
+- (BOOL)canUseCachedDataForRequest:(ASIHTTPRequest *)request
+{
+	// Ensure the request is allowed to read from the cache
+	if ([request cachePolicy] & ASIDoNotReadFromCacheCachePolicy) {
+		return NO;
+
+	// If we don't want to load the request whatever happens, always pretend we have cached data even if we don't
+	} else if ([request cachePolicy] & ASIDontLoadCachePolicy) {
+		return YES;
+	}
+
+	NSDictionary *headers = [self cachedResponseHeadersForURL:[request url]];
+	if (!headers) {
+		return NO;
+	}
+	NSString *dataPath = [self pathToCachedResponseDataForURL:[request url]];
+	if (!dataPath) {
+		return NO;
+	}
+
+	// If we get here, we have cached data
+
+	// If we have cached data, we can use it
+	if ([request cachePolicy] & ASIOnlyLoadIfNotCachedCachePolicy) {
+		return YES;
+
+	// If we want to fallback to the cache after an error
+	} else if ([request complete] && [request cachePolicy] & ASIFallbackToCacheIfLoadFailsCachePolicy) {
+		return YES;
+
+	// If we have cached data that is current, we can use it
+	} else if ([request cachePolicy] & ASIAskServerIfModifiedWhenStaleCachePolicy) {
+		if ([self isCachedDataCurrentForRequest:request]) {
+			return YES;
+		}
+
+	// If we've got headers from a conditional GET and the cached data is still current, we can use it
+	} else if ([request cachePolicy] & ASIAskServerIfModifiedCachePolicy) {
+		if (![request responseHeaders]) {
+			return NO;
+		} else if ([self isCachedDataCurrentForRequest:request]) {
+			return YES;
+		}
+	}
+	return NO;
+}
+
+@synthesize storagePath;
+@synthesize defaultCachePolicy;
+@synthesize accessLock;
+@synthesize shouldRespectCacheControlHeaders;
+@end

+ 75 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIFormDataRequest.h

@@ -0,0 +1,75 @@
+//
+//  ASIFormDataRequest.h
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 07/11/2008.
+//  Copyright 2008-2009 All-Seeing Interactive. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "ASIHTTPRequest.h"
+#import "ASIHTTPRequestConfig.h"
+
+typedef enum _ASIPostFormat {
+    ASIMultipartFormDataPostFormat = 0,
+    ASIURLEncodedPostFormat = 1
+	
+} ASIPostFormat;
+
+@interface ASIFormDataRequest : ASIHTTPRequest <NSCopying> {
+
+	// Parameters that will be POSTed to the url
+	NSMutableArray *postData;
+	
+	// Files that will be POSTed to the url
+	NSMutableArray *fileData;
+	
+	ASIPostFormat postFormat;
+	
+	NSStringEncoding stringEncoding;
+	
+#if DEBUG_FORM_DATA_REQUEST
+	// Will store a string version of the request body that will be printed to the console when ASIHTTPREQUEST_DEBUG is set in GCC_PREPROCESSOR_DEFINITIONS
+	NSString *debugBodyString;
+#endif
+	
+}
+
+#pragma mark utilities 
+- (NSString*)encodeURL:(NSString *)string; 
+ 
+#pragma mark setup request
+
+// Add a POST variable to the request
+- (void)addPostValue:(id <NSObject>)value forKey:(NSString *)key;
+
+// Set a POST variable for this request, clearing any others with the same key
+- (void)setPostValue:(id <NSObject>)value forKey:(NSString *)key;
+
+// Add the contents of a local file to the request
+- (void)addFile:(NSString *)filePath forKey:(NSString *)key;
+
+// Same as above, but you can specify the content-type and file name
+- (void)addFile:(NSString *)filePath withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
+
+// Add the contents of a local file to the request, clearing any others with the same key
+- (void)setFile:(NSString *)filePath forKey:(NSString *)key;
+
+// Same as above, but you can specify the content-type and file name
+- (void)setFile:(NSString *)filePath withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
+
+// Add the contents of an NSData object to the request
+- (void)addData:(NSData *)data forKey:(NSString *)key;
+
+// Same as above, but you can specify the content-type and file name
+- (void)addData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
+
+// Add the contents of an NSData object to the request, clearing any others with the same key
+- (void)setData:(NSData *)data forKey:(NSString *)key;
+
+// Same as above, but you can specify the content-type and file name
+- (void)setData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
+
+@property (atomic, assign) ASIPostFormat postFormat;
+@property (atomic, assign) NSStringEncoding stringEncoding;
+@end

+ 362 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIFormDataRequest.m

@@ -0,0 +1,362 @@
+//
+//  ASIFormDataRequest.m
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 07/11/2008.
+//  Copyright 2008-2009 All-Seeing Interactive. All rights reserved.
+//
+
+#import "ASIFormDataRequest.h"
+
+
+// Private stuff
+@interface ASIFormDataRequest ()
+- (void)buildMultipartFormDataPostBody;
+- (void)buildURLEncodedPostBody;
+- (void)appendPostString:(NSString *)string;
+
+@property (atomic, retain) NSMutableArray *postData;
+@property (atomic, retain) NSMutableArray *fileData;
+
+#if DEBUG_FORM_DATA_REQUEST
+- (void)addToDebugBody:(NSString *)string;
+@property (retain, nonatomic) NSString *debugBodyString;
+#endif
+
+@end
+
+@implementation ASIFormDataRequest
+
+#pragma mark utilities
+- (NSString*)encodeURL:(NSString *)string
+{
+	NSString *newString = [NSMakeCollectable(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding([self stringEncoding]))) autorelease];
+	if (newString) {
+		return newString;
+	}
+	return @"";
+}
+
+#pragma mark init / dealloc
+
++ (id)requestWithURL:(NSURL *)newURL
+{
+	return [[[self alloc] initWithURL:newURL] autorelease];
+}
+
+- (id)initWithURL:(NSURL *)newURL
+{
+	self = [super initWithURL:newURL];
+	[self setPostFormat:ASIURLEncodedPostFormat];
+	[self setStringEncoding:NSUTF8StringEncoding];
+        [self setRequestMethod:@"POST"];
+	return self;
+}
+
+- (void)dealloc
+{
+#if DEBUG_FORM_DATA_REQUEST
+	[debugBodyString release]; 
+#endif
+	
+	[postData release];
+	[fileData release];
+	[super dealloc];
+}
+
+#pragma mark setup request
+
+- (void)addPostValue:(id <NSObject>)value forKey:(NSString *)key
+{
+	if (!key) {
+		return;
+	}
+	if (![self postData]) {
+		[self setPostData:[NSMutableArray array]];
+	}
+	NSMutableDictionary *keyValuePair = [NSMutableDictionary dictionaryWithCapacity:2];
+	[keyValuePair setValue:key forKey:@"key"];
+	[keyValuePair setValue:[value description] forKey:@"value"];
+	[[self postData] addObject:keyValuePair];
+}
+
+- (void)setPostValue:(id <NSObject>)value forKey:(NSString *)key
+{
+	// Remove any existing value
+	NSUInteger i;
+	for (i=0; i<[[self postData] count]; i++) {
+		NSDictionary *val = [[self postData] objectAtIndex:i];
+		if ([[val objectForKey:@"key"] isEqualToString:key]) {
+			[[self postData] removeObjectAtIndex:i];
+			i--;
+		}
+	}
+	[self addPostValue:value forKey:key];
+}
+
+
+- (void)addFile:(NSString *)filePath forKey:(NSString *)key
+{
+	[self addFile:filePath withFileName:nil andContentType:nil forKey:key];
+}
+
+- (void)addFile:(NSString *)filePath withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key
+{
+	BOOL isDirectory = NO;
+	BOOL fileExists = [[[[NSFileManager alloc] init] autorelease] fileExistsAtPath:filePath isDirectory:&isDirectory];
+	if (!fileExists || isDirectory) {
+		[self failWithError:[NSError errorWithDomain:NetworkRequestErrorDomain code:ASIInternalErrorWhileBuildingRequestType userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"No file exists at %@",filePath],NSLocalizedDescriptionKey,nil]]];
+	}
+
+	// If the caller didn't specify a custom file name, we'll use the file name of the file we were passed
+	if (!fileName) {
+		fileName = [filePath lastPathComponent];
+	}
+
+	// If we were given the path to a file, and the user didn't specify a mime type, we can detect it from the file extension
+	if (!contentType) {
+		contentType = [ASIHTTPRequest mimeTypeForFileAtPath:filePath];
+	}
+	[self addData:filePath withFileName:fileName andContentType:contentType forKey:key];
+}
+
+- (void)setFile:(NSString *)filePath forKey:(NSString *)key
+{
+	[self setFile:filePath withFileName:nil andContentType:nil forKey:key];
+}
+
+- (void)setFile:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key
+{
+	// Remove any existing value
+	NSUInteger i;
+	for (i=0; i<[[self fileData] count]; i++) {
+		NSDictionary *val = [[self fileData] objectAtIndex:i];
+		if ([[val objectForKey:@"key"] isEqualToString:key]) {
+			[[self fileData] removeObjectAtIndex:i];
+			i--;
+		}
+	}
+	[self addFile:data withFileName:fileName andContentType:contentType forKey:key];
+}
+
+- (void)addData:(NSData *)data forKey:(NSString *)key
+{
+	[self addData:data withFileName:@"file" andContentType:nil forKey:key];
+}
+
+- (void)addData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key
+{
+	if (![self fileData]) {
+		[self setFileData:[NSMutableArray array]];
+	}
+	if (!contentType) {
+		contentType = @"application/octet-stream";
+	}
+
+	NSMutableDictionary *fileInfo = [NSMutableDictionary dictionaryWithCapacity:4];
+	[fileInfo setValue:key forKey:@"key"];
+	[fileInfo setValue:fileName forKey:@"fileName"];
+	[fileInfo setValue:contentType forKey:@"contentType"];
+	[fileInfo setValue:data forKey:@"data"];
+
+	[[self fileData] addObject:fileInfo];
+}
+
+- (void)setData:(NSData *)data forKey:(NSString *)key
+{
+	[self setData:data withFileName:@"file" andContentType:nil forKey:key];
+}
+
+- (void)setData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key
+{
+	// Remove any existing value
+	NSUInteger i;
+	for (i=0; i<[[self fileData] count]; i++) {
+		NSDictionary *val = [[self fileData] objectAtIndex:i];
+		if ([[val objectForKey:@"key"] isEqualToString:key]) {
+			[[self fileData] removeObjectAtIndex:i];
+			i--;
+		}
+	}
+	[self addData:data withFileName:fileName andContentType:contentType forKey:key];
+}
+
+- (void)buildPostBody
+{
+	if ([self haveBuiltPostBody]) {
+		return;
+	}
+	
+#if DEBUG_FORM_DATA_REQUEST
+	[self setDebugBodyString:@""];	
+#endif
+	
+	if (![self postData] && ![self fileData]) {
+		[super buildPostBody];
+		return;
+	}	
+	if ([[self fileData] count] > 0) {
+		[self setShouldStreamPostDataFromDisk:YES];
+	}
+	
+	if ([self postFormat] == ASIURLEncodedPostFormat) {
+		[self buildURLEncodedPostBody];
+	} else {
+		[self buildMultipartFormDataPostBody];
+	}
+
+	[super buildPostBody];
+	
+#if DEBUG_FORM_DATA_REQUEST
+	ASI_DEBUG_LOG(@"%@",[self debugBodyString]);
+	[self setDebugBodyString:nil];
+#endif
+}
+
+
+- (void)buildMultipartFormDataPostBody
+{
+#if DEBUG_FORM_DATA_REQUEST
+	[self addToDebugBody:@"\r\n==== Building a multipart/form-data body ====\r\n"];
+#endif
+	
+	NSString *charset = (NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding([self stringEncoding]));
+	
+	// We don't bother to check if post data contains the boundary, since it's pretty unlikely that it does.
+	CFUUIDRef uuid = CFUUIDCreate(nil);
+	NSString *uuidString = [(NSString*)CFUUIDCreateString(nil, uuid) autorelease];
+	CFRelease(uuid);
+	NSString *stringBoundary = [NSString stringWithFormat:@"0xKhTmLbOuNdArY-%@",uuidString];
+	
+	[self addRequestHeader:@"Content-Type" value:[NSString stringWithFormat:@"multipart/form-data; charset=%@; boundary=%@", charset, stringBoundary]];
+	
+	[self appendPostString:[NSString stringWithFormat:@"--%@\r\n",stringBoundary]];
+	
+	// Adds post data
+	NSString *endItemBoundary = [NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary];
+	NSUInteger i=0;
+	for (NSDictionary *val in [self postData]) {
+		[self appendPostString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n",[val objectForKey:@"key"]]];
+		[self appendPostString:[val objectForKey:@"value"]];
+		i++;
+		if (i != [[self postData] count] || [[self fileData] count] > 0) { //Only add the boundary if this is not the last item in the post body
+			[self appendPostString:endItemBoundary];
+		}
+	}
+	
+	// Adds files to upload
+	i=0;
+	for (NSDictionary *val in [self fileData]) {
+
+		[self appendPostString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", [val objectForKey:@"key"], [val objectForKey:@"fileName"]]];
+		[self appendPostString:[NSString stringWithFormat:@"Content-Type: %@\r\n\r\n", [val objectForKey:@"contentType"]]];
+		
+		id data = [val objectForKey:@"data"];
+		if ([data isKindOfClass:[NSString class]]) {
+			[self appendPostDataFromFile:data];
+		} else {
+			[self appendPostData:data];
+		}
+		i++;
+		// Only add the boundary if this is not the last item in the post body
+		if (i != [[self fileData] count]) { 
+			[self appendPostString:endItemBoundary];
+		}
+	}
+	
+	[self appendPostString:[NSString stringWithFormat:@"\r\n--%@--\r\n",stringBoundary]];
+	
+#if DEBUG_FORM_DATA_REQUEST
+	[self addToDebugBody:@"==== End of multipart/form-data body ====\r\n"];
+#endif
+}
+
+- (void)buildURLEncodedPostBody
+{
+
+	// We can't post binary data using application/x-www-form-urlencoded
+	if ([[self fileData] count] > 0) {
+		[self setPostFormat:ASIMultipartFormDataPostFormat];
+		[self buildMultipartFormDataPostBody];
+		return;
+	}
+	
+#if DEBUG_FORM_DATA_REQUEST
+	[self addToDebugBody:@"\r\n==== Building an application/x-www-form-urlencoded body ====\r\n"]; 
+#endif
+	
+	
+	NSString *charset = (NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding([self stringEncoding]));
+
+	[self addRequestHeader:@"Content-Type" value:[NSString stringWithFormat:@"application/x-www-form-urlencoded; charset=%@",charset]];
+
+	
+	NSUInteger i=0;
+	NSUInteger count = [[self postData] count]-1;
+	for (NSDictionary *val in [self postData]) {
+        NSString *data = [NSString stringWithFormat:@"%@=%@%@", [self encodeURL:[val objectForKey:@"key"]], [self encodeURL:[val objectForKey:@"value"]],(i<count ?  @"&" : @"")]; 
+		[self appendPostString:data];
+		i++;
+	}
+#if DEBUG_FORM_DATA_REQUEST
+	[self addToDebugBody:@"\r\n==== End of application/x-www-form-urlencoded body ====\r\n"]; 
+#endif
+}
+
+- (void)appendPostString:(NSString *)string
+{
+#if DEBUG_FORM_DATA_REQUEST
+	[self addToDebugBody:string];
+#endif
+	[super appendPostData:[string dataUsingEncoding:[self stringEncoding]]];
+}
+
+#if DEBUG_FORM_DATA_REQUEST
+- (void)appendPostData:(NSData *)data
+{
+	[self addToDebugBody:[NSString stringWithFormat:@"[%lu bytes of data]",(unsigned long)[data length]]];
+	[super appendPostData:data];
+}
+
+- (void)appendPostDataFromFile:(NSString *)file
+{
+	NSError *err = nil;
+	unsigned long long fileSize = [[[[[[NSFileManager alloc] init] autorelease] attributesOfItemAtPath:file error:&err] objectForKey:NSFileSize] unsignedLongLongValue];
+	if (err) {
+		[self addToDebugBody:[NSString stringWithFormat:@"[Error: Failed to obtain the size of the file at '%@']",file]];
+	} else {
+		[self addToDebugBody:[NSString stringWithFormat:@"[%llu bytes of data from file '%@']",fileSize,file]];
+	}
+
+	[super appendPostDataFromFile:file];
+}
+
+- (void)addToDebugBody:(NSString *)string
+{
+	if (string) {
+		[self setDebugBodyString:[[self debugBodyString] stringByAppendingString:string]];
+	}
+}
+#endif
+
+#pragma mark NSCopying
+
+- (id)copyWithZone:(NSZone *)zone
+{
+	ASIFormDataRequest *newRequest = [super copyWithZone:zone];
+	[newRequest setPostData:[[[self postData] mutableCopyWithZone:zone] autorelease]];
+	[newRequest setFileData:[[[self fileData] mutableCopyWithZone:zone] autorelease]];
+	[newRequest setPostFormat:[self postFormat]];
+	[newRequest setStringEncoding:[self stringEncoding]];
+	[newRequest setRequestMethod:[self requestMethod]];
+	return newRequest;
+}
+
+@synthesize postData;
+@synthesize fileData;
+@synthesize postFormat;
+@synthesize stringEncoding;
+#if DEBUG_FORM_DATA_REQUEST
+@synthesize debugBodyString;
+#endif
+@end

File diff suppressed because it is too large
+ 1004 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIHTTPRequest.h


File diff suppressed because it is too large
+ 5138 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIHTTPRequest.m


+ 43 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIHTTPRequestConfig.h

@@ -0,0 +1,43 @@
+//
+//  ASIHTTPRequestConfig.h
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 14/12/2009.
+//  Copyright 2009 All-Seeing Interactive. All rights reserved.
+//
+
+
+// ======
+// Debug output configuration options
+// ======
+
+// If defined will use the specified function for debug logging
+// Otherwise use NSLog
+#ifndef ASI_DEBUG_LOG
+    #define ASI_DEBUG_LOG NSLog
+#endif
+
+// When set to 1 ASIHTTPRequests will print information about what a request is doing
+#ifndef DEBUG_REQUEST_STATUS
+	#define DEBUG_REQUEST_STATUS 0
+#endif
+
+// When set to 1, ASIFormDataRequests will print information about the request body to the console
+#ifndef DEBUG_FORM_DATA_REQUEST
+	#define DEBUG_FORM_DATA_REQUEST 0
+#endif
+
+// When set to 1, ASIHTTPRequests will print information about bandwidth throttling to the console
+#ifndef DEBUG_THROTTLING
+	#define DEBUG_THROTTLING 0
+#endif
+
+// When set to 1, ASIHTTPRequests will print information about persistent connections to the console
+#ifndef DEBUG_PERSISTENT_CONNECTIONS
+	#define DEBUG_PERSISTENT_CONNECTIONS 0
+#endif
+
+// When set to 1, ASIHTTPRequests will print information about HTTP authentication (Basic, Digest or NTLM) to the console
+#ifndef DEBUG_HTTP_AUTHENTICATION
+    #define DEBUG_HTTP_AUTHENTICATION 0
+#endif

+ 35 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIHTTPRequestDelegate.h

@@ -0,0 +1,35 @@
+//
+//  ASIHTTPRequestDelegate.h
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 13/04/2010.
+//  Copyright 2010 All-Seeing Interactive. All rights reserved.
+//
+
+@class ASIHTTPRequest;
+
+@protocol ASIHTTPRequestDelegate <NSObject>
+
+@optional
+
+// These are the default delegate methods for request status
+// You can use different ones by setting didStartSelector / didFinishSelector / didFailSelector
+- (void)requestStarted:(ASIHTTPRequest *)request;
+- (void)request:(ASIHTTPRequest *)request didReceiveResponseHeaders:(NSDictionary *)responseHeaders;
+- (void)request:(ASIHTTPRequest *)request willRedirectToURL:(NSURL *)newURL;
+- (void)requestFinished:(ASIHTTPRequest *)request;
+- (void)requestFailed:(ASIHTTPRequest *)request;
+- (void)requestRedirected:(ASIHTTPRequest *)request;
+
+// When a delegate implements this method, it is expected to process all incoming data itself
+// This means that responseData / responseString / downloadDestinationPath etc are ignored
+// You can have the request call a different method by setting didReceiveDataSelector
+- (void)request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data;
+
+// If a delegate implements one of these, it will be asked to supply credentials when none are available
+// The delegate can then either restart the request ([request retryUsingSuppliedCredentials]) once credentials have been set
+// or cancel it ([request cancelAuthentication])
+- (void)authenticationNeededForRequest:(ASIHTTPRequest *)request;
+- (void)proxyAuthenticationNeededForRequest:(ASIHTTPRequest *)request;
+
+@end

+ 26 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIInputStream.h

@@ -0,0 +1,26 @@
+//
+//  ASIInputStream.h
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 10/08/2009.
+//  Copyright 2009 All-Seeing Interactive. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@class ASIHTTPRequest;
+
+// This is a wrapper for NSInputStream that pretends to be an NSInputStream itself
+// Subclassing NSInputStream seems to be tricky, and may involve overriding undocumented methods, so we'll cheat instead.
+// It is used by ASIHTTPRequest whenever we have a request body, and handles measuring and throttling the bandwidth used for uploading
+
+@interface ASIInputStream : NSObject {
+	NSInputStream *stream;
+	ASIHTTPRequest *request;
+}
++ (id)inputStreamWithFileAtPath:(NSString *)path request:(ASIHTTPRequest *)request;
++ (id)inputStreamWithData:(NSData *)data request:(ASIHTTPRequest *)request;
+
+@property (retain, nonatomic) NSInputStream *stream;
+@property (assign, nonatomic) ASIHTTPRequest *request;
+@end

+ 138 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIInputStream.m

@@ -0,0 +1,138 @@
+//
+//  ASIInputStream.m
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 10/08/2009.
+//  Copyright 2009 All-Seeing Interactive. All rights reserved.
+//
+
+#import "ASIInputStream.h"
+#import "ASIHTTPRequest.h"
+
+// Used to ensure only one request can read data at once
+static NSLock *readLock = nil;
+
+@implementation ASIInputStream
+
++ (void)initialize
+{
+	if (self == [ASIInputStream class]) {
+		readLock = [[NSLock alloc] init];
+	}
+}
+
++ (id)inputStreamWithFileAtPath:(NSString *)path request:(ASIHTTPRequest *)theRequest
+{
+	ASIInputStream *theStream = [[[self alloc] init] autorelease];
+	[theStream setRequest:theRequest];
+	[theStream setStream:[NSInputStream inputStreamWithFileAtPath:path]];
+	return theStream;
+}
+
++ (id)inputStreamWithData:(NSData *)data request:(ASIHTTPRequest *)theRequest
+{
+	ASIInputStream *theStream = [[[self alloc] init] autorelease];
+	[theStream setRequest:theRequest];
+	[theStream setStream:[NSInputStream inputStreamWithData:data]];
+	return theStream;
+}
+
+- (void)dealloc
+{
+	[stream release];
+	[super dealloc];
+}
+
+// Called when CFNetwork wants to read more of our request body
+// When throttling is on, we ask ASIHTTPRequest for the maximum amount of data we can read
+- (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)len
+{
+	[readLock lock];
+	unsigned long toRead = len;
+	if ([ASIHTTPRequest isBandwidthThrottled]) {
+		toRead = [ASIHTTPRequest maxUploadReadLength];
+		if (toRead > len) {
+			toRead = len;
+		} else if (toRead == 0) {
+			toRead = 1;
+		}
+		[request performThrottling];
+	}
+	[readLock unlock];
+	NSInteger rv = [stream read:buffer maxLength:toRead];
+	if (rv > 0)
+		[ASIHTTPRequest incrementBandwidthUsedInLastSecond:(NSUInteger)rv];
+	return rv;
+}
+
+/*
+ * Implement NSInputStream mandatory methods to make sure they are implemented
+ * (necessary for MacRuby for example) and avoid the overhead of method
+ * forwarding for these common methods.
+ */
+- (void)open
+{
+    [stream open];
+}
+
+- (void)close
+{
+    [stream close];
+}
+
+- (id)delegate
+{
+    return [stream delegate];
+}
+
+- (void)setDelegate:(id)delegate
+{
+    [stream setDelegate:delegate];
+}
+
+- (void)scheduleInRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode
+{
+    [stream scheduleInRunLoop:aRunLoop forMode:mode];
+}
+
+- (void)removeFromRunLoop:(NSRunLoop *)aRunLoop forMode:(NSString *)mode
+{
+    [stream removeFromRunLoop:aRunLoop forMode:mode];
+}
+
+- (id)propertyForKey:(NSString *)key
+{
+    return [stream propertyForKey:key];
+}
+
+- (BOOL)setProperty:(id)property forKey:(NSString *)key
+{
+    return [stream setProperty:property forKey:key];
+}
+
+- (NSStreamStatus)streamStatus
+{
+    return [stream streamStatus];
+}
+
+- (NSError *)streamError
+{
+    return [stream streamError];
+}
+
+// If we get asked to perform a method we don't have (probably internal ones),
+// we'll just forward the message to our stream
+
+- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
+{
+	return [stream methodSignatureForSelector:aSelector];
+}
+	 
+- (void)forwardInvocation:(NSInvocation *)anInvocation
+{
+	[anInvocation invokeWithTarget:stream];
+}
+
+@synthesize stream;
+@synthesize request;
+@end

+ 108 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASINetworkQueue.h

@@ -0,0 +1,108 @@
+//
+//  ASINetworkQueue.h
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 07/11/2008.
+//  Copyright 2008-2009 All-Seeing Interactive. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "ASIHTTPRequestDelegate.h"
+#import "ASIProgressDelegate.h"
+
+@interface ASINetworkQueue : NSOperationQueue <ASIProgressDelegate, ASIHTTPRequestDelegate, NSCopying> {
+	
+	// Delegate will get didFail + didFinish messages (if set)
+	id delegate;
+
+	// Will be called when a request starts with the request as the argument
+	SEL requestDidStartSelector;
+	
+	// Will be called when a request receives response headers
+	// Should take the form request:didRecieveResponseHeaders:, where the first argument is the request, and the second the headers dictionary
+	SEL requestDidReceiveResponseHeadersSelector;
+	
+	// Will be called when a request is about to redirect
+	// Should take the form request:willRedirectToURL:, where the first argument is the request, and the second the new url
+	SEL requestWillRedirectSelector;
+
+	// Will be called when a request completes with the request as the argument
+	SEL requestDidFinishSelector;
+	
+	// Will be called when a request fails with the request as the argument
+	SEL requestDidFailSelector;
+	
+	// Will be called when the queue finishes with the queue as the argument
+	SEL queueDidFinishSelector;
+	
+	// Upload progress indicator, probably an NSProgressIndicator or UIProgressView
+	id uploadProgressDelegate;
+	
+	// Total amount uploaded so far for all requests in this queue
+	unsigned long long bytesUploadedSoFar;
+	
+	// Total amount to be uploaded for all requests in this queue - requests add to this figure as they work out how much data they have to transmit
+	unsigned long long totalBytesToUpload;
+
+	// Download progress indicator, probably an NSProgressIndicator or UIProgressView
+	id downloadProgressDelegate;
+	
+	// Total amount downloaded so far for all requests in this queue
+	unsigned long long bytesDownloadedSoFar;
+	
+	// Total amount to be downloaded for all requests in this queue - requests add to this figure as they receive Content-Length headers
+	unsigned long long totalBytesToDownload;
+	
+	// When YES, the queue will cancel all requests when a request fails. Default is YES
+	BOOL shouldCancelAllRequestsOnFailure;
+	
+	//Number of real requests (excludes HEAD requests created to manage showAccurateProgress)
+	int requestsCount;
+	
+	// When NO, this request will only update the progress indicator when it completes
+	// When YES, this request will update the progress indicator according to how much data it has received so far
+	// When YES, the queue will first perform HEAD requests for all GET requests in the queue, so it can calculate the total download size before it starts
+	// NO means better performance, because it skips this step for GET requests, and it won't waste time updating the progress indicator until a request completes 
+	// Set to YES if the size of a requests in the queue varies greatly for much more accurate results
+	// Default for requests in the queue is NO
+	BOOL showAccurateProgress;
+
+	// Storage container for additional queue information.
+	NSDictionary *userInfo;
+	
+}
+
+// Convenience constructor
++ (id)queue;
+
+// Call this to reset a queue - it will cancel all operations, clear delegates, and suspend operation
+- (void)reset;
+
+// Used internally to manage HEAD requests when showAccurateProgress is YES, do not use!
+- (void)addHEADOperation:(NSOperation *)operation;
+
+// All ASINetworkQueues are paused when created so that total size can be calculated before the queue starts
+// This method will start the queue
+- (void)go;
+
+@property (assign, nonatomic, setter=setUploadProgressDelegate:) id uploadProgressDelegate;
+@property (assign, nonatomic, setter=setDownloadProgressDelegate:) id downloadProgressDelegate;
+
+@property (assign, atomic) SEL requestDidStartSelector;
+@property (assign, atomic) SEL requestDidReceiveResponseHeadersSelector;
+@property (assign, atomic) SEL requestWillRedirectSelector;
+@property (assign, atomic) SEL requestDidFinishSelector;
+@property (assign, atomic) SEL requestDidFailSelector;
+@property (assign, atomic) SEL queueDidFinishSelector;
+@property (assign, atomic) BOOL shouldCancelAllRequestsOnFailure;
+@property (assign, atomic) id delegate;
+@property (assign, atomic) BOOL showAccurateProgress;
+@property (assign, atomic, readonly) int requestsCount;
+@property (retain, atomic) NSDictionary *userInfo;
+
+@property (assign, atomic) unsigned long long bytesUploadedSoFar;
+@property (assign, atomic) unsigned long long totalBytesToUpload;
+@property (assign, atomic) unsigned long long bytesDownloadedSoFar;
+@property (assign, atomic) unsigned long long totalBytesToDownload;
+
+@end

+ 343 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASINetworkQueue.m

@@ -0,0 +1,343 @@
+//
+//  ASINetworkQueue.m
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 07/11/2008.
+//  Copyright 2008-2009 All-Seeing Interactive. All rights reserved.
+//
+
+#import "ASINetworkQueue.h"
+#import "ASIHTTPRequest.h"
+
+// Private stuff
+@interface ASINetworkQueue ()
+	- (void)resetProgressDelegate:(id *)progressDelegate;
+	@property (assign) int requestsCount;
+@end
+
+@implementation ASINetworkQueue
+
+- (id)init
+{
+	self = [super init];
+	[self setShouldCancelAllRequestsOnFailure:YES];
+	[self setMaxConcurrentOperationCount:4];
+	[self setSuspended:YES];
+	
+	return self;
+}
+
++ (id)queue
+{
+	return [[[self alloc] init] autorelease];
+}
+
+- (void)dealloc
+{
+	//We need to clear the queue on any requests that haven't got around to cleaning up yet, as otherwise they'll try to let us know if something goes wrong, and we'll be long gone by then
+	for (ASIHTTPRequest *request in [self operations]) {
+		[request setQueue:nil];
+	}
+	[userInfo release];
+	[super dealloc];
+}
+
+- (void)setSuspended:(BOOL)suspend
+{
+	[super setSuspended:suspend];
+}
+
+- (void)reset
+{
+	[self cancelAllOperations];
+	[self setDelegate:nil];
+	[self setDownloadProgressDelegate:nil];
+	[self setUploadProgressDelegate:nil];
+	[self setRequestDidStartSelector:NULL];
+	[self setRequestDidReceiveResponseHeadersSelector:NULL];
+	[self setRequestDidFailSelector:NULL];
+	[self setRequestDidFinishSelector:NULL];
+	[self setQueueDidFinishSelector:NULL];
+	[self setSuspended:YES];
+}
+
+
+- (void)go
+{
+	[self setSuspended:NO];
+}
+
+- (void)cancelAllOperations
+{
+	[self setBytesUploadedSoFar:0];
+	[self setTotalBytesToUpload:0];
+	[self setBytesDownloadedSoFar:0];
+	[self setTotalBytesToDownload:0];
+	[super cancelAllOperations];
+}
+
+- (void)setUploadProgressDelegate:(id)newDelegate
+{
+	uploadProgressDelegate = newDelegate;
+	[self resetProgressDelegate:&uploadProgressDelegate];
+
+}
+
+- (void)setDownloadProgressDelegate:(id)newDelegate
+{
+	downloadProgressDelegate = newDelegate;
+	[self resetProgressDelegate:&downloadProgressDelegate];
+}
+
+- (void)resetProgressDelegate:(id *)progressDelegate
+{
+#if !TARGET_OS_IPHONE
+	// If the uploadProgressDelegate is an NSProgressIndicator, we set its MaxValue to 1.0 so we can treat it similarly to UIProgressViews
+	SEL selector = @selector(setMaxValue:);
+	if ([*progressDelegate respondsToSelector:selector]) {
+		double max = 1.0;
+		[ASIHTTPRequest performSelector:selector onTarget:progressDelegate withObject:nil amount:&max callerToRetain:nil];
+	}
+	selector = @selector(setDoubleValue:);
+	if ([*progressDelegate respondsToSelector:selector]) {
+		double value = 0.0;
+		[ASIHTTPRequest performSelector:selector onTarget:progressDelegate withObject:nil amount:&value callerToRetain:nil];
+	}
+#else
+	SEL selector = @selector(setProgress:);
+	if ([*progressDelegate respondsToSelector:selector]) {
+		float value = 0.0f;
+		[ASIHTTPRequest performSelector:selector onTarget:progressDelegate withObject:nil amount:&value callerToRetain:nil];
+	}
+#endif
+}
+
+- (void)addHEADOperation:(NSOperation *)operation
+{
+	if ([operation isKindOfClass:[ASIHTTPRequest class]]) {
+		
+		ASIHTTPRequest *request = (ASIHTTPRequest *)operation;
+		[request setRequestMethod:@"HEAD"];
+		[request setQueuePriority:10];
+		[request setShowAccurateProgress:YES];
+		[request setQueue:self];
+		
+		// Important - we are calling NSOperation's add method - we don't want to add this as a normal request!
+		[super addOperation:request];
+	}
+}
+
+// Only add ASIHTTPRequests to this queue!!
+- (void)addOperation:(NSOperation *)operation
+{
+	if (![operation isKindOfClass:[ASIHTTPRequest class]]) {
+		[NSException raise:@"AttemptToAddInvalidRequest" format:@"Attempted to add an object that was not an ASIHTTPRequest to an ASINetworkQueue"];
+	}
+		
+	[self setRequestsCount:[self requestsCount]+1];
+	
+	ASIHTTPRequest *request = (ASIHTTPRequest *)operation;
+	
+	if ([self showAccurateProgress]) {
+		
+		// Force the request to build its body (this may change requestMethod)
+		[request buildPostBody];
+		
+		// If this is a GET request and we want accurate progress, perform a HEAD request first to get the content-length
+		// We'll only do this before the queue is started
+		// If requests are added after the queue is started they will probably move the overall progress backwards anyway, so there's no value performing the HEAD requests first
+		// Instead, they'll update the total progress if and when they receive a content-length header
+		if ([[request requestMethod] isEqualToString:@"GET"]) {
+			if ([self isSuspended]) {
+				ASIHTTPRequest *HEADRequest = [request HEADRequest];
+				[self addHEADOperation:HEADRequest];
+				[request addDependency:HEADRequest];
+				if ([request shouldResetDownloadProgress]) {
+					[self resetProgressDelegate:&downloadProgressDelegate];
+					[request setShouldResetDownloadProgress:NO];
+				}
+			}
+		}
+		[request buildPostBody];
+		[self request:nil incrementUploadSizeBy:(long long)[request postLength]];
+
+
+	} else {
+		[self request:nil incrementDownloadSizeBy:1];
+		[self request:nil incrementUploadSizeBy:1];
+	}
+	// Tell the request not to increment the upload size when it starts, as we've already added its length
+	if ([request shouldResetUploadProgress]) {
+		[self resetProgressDelegate:&uploadProgressDelegate];
+		[request setShouldResetUploadProgress:NO];
+	}
+	
+	[request setShowAccurateProgress:[self showAccurateProgress]];
+	
+	[request setQueue:self];
+	[super addOperation:request];
+
+}
+
+- (void)requestStarted:(ASIHTTPRequest *)request
+{
+	if ([self requestDidStartSelector]) {
+		[[self delegate] performSelector:[self requestDidStartSelector] withObject:request];
+	}
+}
+
+- (void)request:(ASIHTTPRequest *)request didReceiveResponseHeaders:(NSDictionary *)responseHeaders
+{
+	if ([self requestDidReceiveResponseHeadersSelector]) {
+		[[self delegate] performSelector:[self requestDidReceiveResponseHeadersSelector] withObject:request withObject:responseHeaders];
+	}
+}
+
+- (void)request:(ASIHTTPRequest *)request willRedirectToURL:(NSURL *)newURL
+{
+	if ([self requestWillRedirectSelector]) {
+		[[self delegate] performSelector:[self requestWillRedirectSelector] withObject:request withObject:newURL];
+	}
+}
+
+- (void)requestFinished:(ASIHTTPRequest *)request
+{
+	[self setRequestsCount:[self requestsCount]-1];
+	if ([self requestDidFinishSelector]) {
+		[[self delegate] performSelector:[self requestDidFinishSelector] withObject:request];
+	}
+	if ([self requestsCount] == 0) {
+		if ([self queueDidFinishSelector]) {
+			[[self delegate] performSelector:[self queueDidFinishSelector] withObject:self];
+		}
+	}
+}
+
+- (void)requestFailed:(ASIHTTPRequest *)request
+{
+	[self setRequestsCount:[self requestsCount]-1];
+	if ([self requestDidFailSelector]) {
+		[[self delegate] performSelector:[self requestDidFailSelector] withObject:request];
+	}
+	if ([self requestsCount] == 0) {
+		if ([self queueDidFinishSelector]) {
+			[[self delegate] performSelector:[self queueDidFinishSelector] withObject:self];
+		}
+	}
+	if ([self shouldCancelAllRequestsOnFailure] && [self requestsCount] > 0) {
+		[self cancelAllOperations];
+	}
+	
+}
+
+
+- (void)request:(ASIHTTPRequest *)request didReceiveBytes:(long long)bytes
+{
+	[self setBytesDownloadedSoFar:[self bytesDownloadedSoFar]+(unsigned long long)bytes];
+	if ([self downloadProgressDelegate]) {
+		[ASIHTTPRequest updateProgressIndicator:&downloadProgressDelegate withProgress:[self bytesDownloadedSoFar] ofTotal:[self totalBytesToDownload]];
+	}
+}
+
+- (void)request:(ASIHTTPRequest *)request didSendBytes:(long long)bytes
+{
+	[self setBytesUploadedSoFar:[self bytesUploadedSoFar]+(unsigned long long)bytes];
+	if ([self uploadProgressDelegate]) {
+		[ASIHTTPRequest updateProgressIndicator:&uploadProgressDelegate withProgress:[self bytesUploadedSoFar] ofTotal:[self totalBytesToUpload]];
+	}
+}
+
+- (void)request:(ASIHTTPRequest *)request incrementDownloadSizeBy:(long long)newLength
+{
+	[self setTotalBytesToDownload:[self totalBytesToDownload]+(unsigned long long)newLength];
+}
+
+- (void)request:(ASIHTTPRequest *)request incrementUploadSizeBy:(long long)newLength
+{
+	[self setTotalBytesToUpload:[self totalBytesToUpload]+(unsigned long long)newLength];
+}
+
+
+// Since this queue takes over as the delegate for all requests it contains, it should forward authorisation requests to its own delegate
+- (void)authenticationNeededForRequest:(ASIHTTPRequest *)request
+{
+	if ([[self delegate] respondsToSelector:@selector(authenticationNeededForRequest:)]) {
+		[[self delegate] performSelector:@selector(authenticationNeededForRequest:) withObject:request];
+	}
+}
+
+- (void)proxyAuthenticationNeededForRequest:(ASIHTTPRequest *)request
+{
+	if ([[self delegate] respondsToSelector:@selector(proxyAuthenticationNeededForRequest:)]) {
+		[[self delegate] performSelector:@selector(proxyAuthenticationNeededForRequest:) withObject:request];
+	}
+}
+
+
+- (BOOL)respondsToSelector:(SEL)selector
+{
+	// We handle certain methods differently because whether our delegate implements them or not can affect how the request should behave
+
+	// If the delegate implements this, the request will stop to wait for credentials
+	if (selector == @selector(authenticationNeededForRequest:)) {
+		if ([[self delegate] respondsToSelector:@selector(authenticationNeededForRequest:)]) {
+			return YES;
+		}
+		return NO;
+
+	// If the delegate implements this, the request will to wait for credentials
+	} else if (selector == @selector(proxyAuthenticationNeededForRequest:)) {
+		if ([[self delegate] respondsToSelector:@selector(proxyAuthenticationNeededForRequest:)]) {
+			return YES;
+		}
+		return NO;
+
+	// If the delegate implements requestWillRedirectSelector, the request will stop to allow the delegate to change the url
+	} else if (selector == @selector(request:willRedirectToURL:)) {
+		if ([self requestWillRedirectSelector] && [[self delegate] respondsToSelector:[self requestWillRedirectSelector]]) {
+			return YES;
+		}
+		return NO;
+	}
+	return [super respondsToSelector:selector];
+}
+
+#pragma mark NSCopying
+
+- (id)copyWithZone:(NSZone *)zone
+{
+	ASINetworkQueue *newQueue = [[[self class] alloc] init];
+	[newQueue setDelegate:[self delegate]];
+	[newQueue setRequestDidStartSelector:[self requestDidStartSelector]];
+	[newQueue setRequestWillRedirectSelector:[self requestWillRedirectSelector]];
+	[newQueue setRequestDidReceiveResponseHeadersSelector:[self requestDidReceiveResponseHeadersSelector]];
+	[newQueue setRequestDidFinishSelector:[self requestDidFinishSelector]];
+	[newQueue setRequestDidFailSelector:[self requestDidFailSelector]];
+	[newQueue setQueueDidFinishSelector:[self queueDidFinishSelector]];
+	[newQueue setUploadProgressDelegate:[self uploadProgressDelegate]];
+	[newQueue setDownloadProgressDelegate:[self downloadProgressDelegate]];
+	[newQueue setShouldCancelAllRequestsOnFailure:[self shouldCancelAllRequestsOnFailure]];
+	[newQueue setShowAccurateProgress:[self showAccurateProgress]];
+	[newQueue setUserInfo:[[[self userInfo] copyWithZone:zone] autorelease]];
+	return newQueue;
+}
+
+
+@synthesize requestsCount;
+@synthesize bytesUploadedSoFar;
+@synthesize totalBytesToUpload;
+@synthesize bytesDownloadedSoFar;
+@synthesize totalBytesToDownload;
+@synthesize shouldCancelAllRequestsOnFailure;
+@synthesize uploadProgressDelegate;
+@synthesize downloadProgressDelegate;
+@synthesize requestDidStartSelector;
+@synthesize requestDidReceiveResponseHeadersSelector;
+@synthesize requestWillRedirectSelector;
+@synthesize requestDidFinishSelector;
+@synthesize requestDidFailSelector;
+@synthesize queueDidFinishSelector;
+@synthesize delegate;
+@synthesize showAccurateProgress;
+@synthesize userInfo;
+@end

+ 38 - 0
PDF Office/PDF Master/Third Pard Library/ASIHttpRequest/ASIProgressDelegate.h

@@ -0,0 +1,38 @@
+//
+//  ASIProgressDelegate.h
+//  Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
+//
+//  Created by Ben Copsey on 13/04/2010.
+//  Copyright 2010 All-Seeing Interactive. All rights reserved.
+//
+
+@class ASIHTTPRequest;
+
+@protocol ASIProgressDelegate <NSObject>
+
+@optional
+
+// These methods are used to update UIProgressViews (iPhone OS) or NSProgressIndicators (Mac OS X)
+// If you are using a custom progress delegate, you may find it easier to implement didReceiveBytes / didSendBytes instead
+#if TARGET_OS_IPHONE
+- (void)setProgress:(float)newProgress;
+#else
+- (void)setDoubleValue:(double)newProgress;
+- (void)setMaxValue:(double)newMax;
+#endif
+
+// Called when the request receives some data - bytes is the length of that data
+- (void)request:(ASIHTTPRequest *)request didReceiveBytes:(long long)bytes;
+
+// Called when the request sends some data
+// The first 32KB (128KB on older platforms) of data sent is not included in this amount because of limitations with the CFNetwork API
+// bytes may be less than zero if a request needs to remove upload progress (probably because the request needs to run again)
+- (void)request:(ASIHTTPRequest *)request didSendBytes:(long long)bytes;
+
+// Called when a request needs to change the length of the content to download
+- (void)request:(ASIHTTPRequest *)request incrementDownloadSizeBy:(long long)newLength;
+
+// Called when a request needs to change the length of the content to upload
+// newLength may be less than zero when a request needs to remove the size of the internal buffer from progress tracking
+- (void)request:(ASIHTTPRequest *)request incrementUploadSizeBy:(long long)newLength;
+@end