Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Classes/PackageDataResponse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// PackageDataResponse.h
// SDKLauncher-iOS
//
// Created by Oliver Eikemeier on 04.04.14.
// Copyright (c) 2014 txtr GmbH.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#import "HTTPDataResponse.h"

@interface PackageDataResponse : HTTPDataResponse

@property (nonatomic, copy) NSString *contentType;

@end
40 changes: 40 additions & 0 deletions Classes/PackageDataResponse.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// PackageDataResponse.m
// SDKLauncher-iOS
//
// Created by Oliver Eikemeier on 04.04.14.
// Copyright (c) 2014 txtr GmbH.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#import "PackageDataResponse.h"

@implementation PackageDataResponse

- (NSDictionary *)httpHeaders {
if (self.contentType) {
return @{@"Content-Type": self.contentType};
}
else {
return @{};
}
}

@end
15 changes: 11 additions & 4 deletions Classes/PackageResourceConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "PackageResourceConnection.h"
#import "HTTPDataResponse.h"
#import "PackageDataResponse.h"
#import "PackageResourceResponse.h"
#import "PackageResourceServer.h"
#import "RDPackage.h"
Expand All @@ -34,6 +34,8 @@ @implementation PackageResourceConnection
path = [path substringFromIndex:1];
}

NSObject <HTTPResponse> *response = nil;

// Synchronize using a process-level lock to guard against multiple threads accessing a
// resource byte stream, which may lead to instability.

Expand All @@ -51,15 +53,20 @@ @implementation PackageResourceConnection
NSData *data = resource.data;

if (data != nil) {
return [[HTTPDataResponse alloc] initWithData:data];
PackageDataResponse *dataResponse = [[PackageDataResponse alloc] initWithData:data];
if (resource.mimeType) {
dataResponse.contentType = resource.mimeType;
}
response = dataResponse;
}
}
else {
return [[PackageResourceResponse alloc] initWithResource:resource];
PackageResourceResponse *resourceResponse = [[PackageResourceResponse alloc] initWithResource:resource];
response = resourceResponse;
}
}

return nil;
return response;
}


Expand Down
11 changes: 11 additions & 0 deletions Classes/PackageResourceResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,15 @@ - (void)setOffset:(UInt64)offset {
}


- (NSDictionary *)httpHeaders {
NSString *contentType = self->m_resource.mimeType;
if (contentType) {
return @{@"Content-Type": contentType};
}
else {
return @{};
}
}


@end
7 changes: 7 additions & 0 deletions Classes/RDPackage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ - (RDPackageResource *)resourceAtRelativePath:(NSString *)relativePath {

if (resource != nil) {
m_byteStreamVector.push_back(std::move(byteStream));

ePub3::ConstManifestItemPtr item = m_package->ManifestItemAtRelativePath(s);

if (item) {
const ePub3::ManifestItem::MimeType &mediaType = item->MediaType();
resource.mimeType = [NSString stringWithUTF8String:mediaType.c_str()];
}
}

return resource;
Expand Down
2 changes: 2 additions & 0 deletions Classes/RDPackageResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
// The relative path associated with this resource.
@property (nonatomic, readonly) NSString *relativePath;

@property (nonatomic, copy) NSString *mimeType;

- (id)
initWithDelegate:(id <RDPackageResourceDelegate>)delegate
byteStream:(void *)byteStream
Expand Down
31 changes: 0 additions & 31 deletions SDKLauncher-iOS-Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,4 @@

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define SCREEN_SIZE ([UIScreen mainScreen].bounds.size)

// -----------------------------------------
// SimpleHTTPServer requires the following

#define DEBUGLOG false

# define USING_MRR (!__has_feature(objc_arc))

# if defined(OS_OBJECT_USE_OBJC) && OS_OBJECT_USE_OBJC
# define DISPATCH_USES_ARC !USING_MRR
# else
# define DISPATCH_USES_ARC 0
# endif

#if __has_feature(objc_arc) && defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0
# define __maybe_weak __weak
# define __block_weak __weak
# define property_weak weak
#elif __has_feature(objc_arc) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7
# define __maybe_weak __weak
# define __block_weak __weak
# define property_weak weak
#else
# define __maybe_weak __unsafe_unretained
# define __block_weak __block
# define property_weak assign
#endif

// (end SimpleHTTPServer)
// -----------------------------------------

#endif
6 changes: 6 additions & 0 deletions SDKLauncher-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
2DC070A8190AB6070018A6F9 /* PackageDataResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 2DC070A7190AB6070018A6F9 /* PackageDataResponse.m */; };
3403516516CE93F2009E3B88 /* reader.css in Resources */ = {isa = PBXBuildFile; fileRef = 3403516116CE93F2009E3B88 /* reader.css */; };
3403516616CE93F2009E3B88 /* reader.html in Resources */ = {isa = PBXBuildFile; fileRef = 3403516216CE93F2009E3B88 /* reader.html */; };
340535AA16BC5DD100D4A802 /* BaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 340535A916BC5DD100D4A802 /* BaseViewController.m */; };
Expand Down Expand Up @@ -137,6 +138,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
2DC070A6190AB6070018A6F9 /* PackageDataResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PackageDataResponse.h; sourceTree = "<group>"; };
2DC070A7190AB6070018A6F9 /* PackageDataResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PackageDataResponse.m; sourceTree = "<group>"; };
3403516116CE93F2009E3B88 /* reader.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = reader.css; sourceTree = "<group>"; };
3403516216CE93F2009E3B88 /* reader.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = reader.html; sourceTree = "<group>"; };
340535A816BC5DD100D4A802 /* BaseViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -523,6 +526,8 @@
children = (
3499B0C318413C68002D8AEA /* PackageResourceConnection.h */,
3499B0C418413C68002D8AEA /* PackageResourceConnection.m */,
2DC070A6190AB6070018A6F9 /* PackageDataResponse.h */,
2DC070A7190AB6070018A6F9 /* PackageDataResponse.m */,
3434215618D4E826001D4279 /* PackageResourceResponse.h */,
3434215718D4E826001D4279 /* PackageResourceResponse.m */,
34C5534216E15D32003A7C23 /* PackageResourceServer.h */,
Expand Down Expand Up @@ -806,6 +811,7 @@
34DAC6EB18D4BB96004F926A /* DispatchQueueLogFormatter.m in Sources */,
34C4064817A451D100354C33 /* EPubSettings.m in Sources */,
34C4064317A43A1700354C33 /* EPubSettingsController.m in Sources */,
2DC070A8190AB6070018A6F9 /* PackageDataResponse.m in Sources */,
3411DF03175FACC000FCE6D9 /* EPubViewController.m in Sources */,
340535B216BC608900D4A802 /* LocStr.m in Sources */,
340535B316BC608900D4A802 /* LocStrError.m in Sources */,
Expand Down