Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Pull request to update for supporting LCP #46

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions LauncherOSX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@
AD8C8F410069609045A3F696 /* LOXSampleStylesProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LOXSampleStylesProvider.mm; sourceTree = "<group>"; };
AD8C8FBED8EFF09E6381C68F /* LOXBookmarksController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LOXBookmarksController.h; sourceTree = "<group>"; };
AD8C8FEC6F5BC3C8D400A388 /* LOXCurrentPagesInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LOXCurrentPagesInfo.mm; sourceTree = "<group>"; };
FFE961B91C0E81FA00FA2A5C /* drmInitialize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = drmInitialize.h; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -682,6 +683,7 @@
AD8C8C165CD8EBCC0E30AE2F /* ePubSdkApi */ = {
isa = PBXGroup;
children = (
FFE961B91C0E81FA00FA2A5C /* drmInitialize.h */,
855CFE49169B912300AD311E /* LOXePubSdkApi.h */,
855CFE4A169B912300AD311E /* LOXePubSdkApi.mm */,
);
Expand Down
22 changes: 22 additions & 0 deletions LauncherOSX/LOXAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,26 @@ - (IBAction)showPreferences:(id)sender
[self.preferencesController showPreferences:_userData.preferences];
}

// Added by DRM inside, H.S. Lee on 2015-04-23
// To handle checking user rights for the 'print' action
- (IBAction)OpenPrint:(id)sender {

if (_epubApi!=nullptr &&[_epubApi checkActionPrint]) {
NSArray *array = [[_window contentView] subviews];
NSArray *arrayS = [array[2] subviews];
NSArray *arrayW = [arrayS[1] subviews];

NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
NSPrintOperation * printOperation = [[[arrayW[0] mainFrame] frameView] printOperationWithPrintInfo:printInfo];
[printOperation runOperation];
}
else
{
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:@"Print action has no permission"];
[alert addButtonWithTitle:@"Ok"];
[alert runModal];
}
}

@end
4 changes: 4 additions & 0 deletions LauncherOSX/LOXePubSdkApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ namespace ePub3 {

- (LOXPackage *)openFile:(NSString *)file;

// Added by DRM inside, H.S. Lee on 2015-04-23
// To handle checking user rights for the 'print' action
- (bool) checkActionPrint;

@end
27 changes: 27 additions & 0 deletions LauncherOSX/LOXePubSdkApi.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
#import "LOXPackage.h"


#import "LOXAppDelegate.h"
#import <ePub3/user_action.h>
#import "drmInitialize.h"

@interface LOXePubSdkApi ()

Expand Down Expand Up @@ -114,6 +117,14 @@ +(void)initialize

ePub3::InitializeSdk();
ePub3::PopulateFilterManager();

// If launcher wants to include DRM feature,
// READIUM_DRM=1 should be defined in the preporessor macros section
// in the project configuration
#ifdef _READIUM_DRM_
[[[DrmInitialize alloc] init] initialize];
#endif

}

- (id)init
Expand Down Expand Up @@ -167,6 +178,22 @@ - (void)cleanup
}


// Added by DRM inside, H.S. Lee on 2015-04-23
// To handle checking user rights for the 'print' action
- (bool) checkActionPrint
{
if(_container->Creator() != nullptr)
{
ePub3::async_result<bool> result = _container->Creator()->ApproveUserAction(ePub3::UserAction(ePub3::ConstManifestItemPtr(nullptr), ePub3::CFI(), ePub3::ActionType::Print));

return result.get();
}
else
{
return true;
}

}



Expand Down
30 changes: 30 additions & 0 deletions LauncherOSX/drmInitialize.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// DrmInitialize.h
// SDKLauncher-OSX
//
// Created by DRM inside Development Team on 2015-08-16.
// ( T.H. Kim, H.D. Yoon, H.S. Lee and C.H. Yu )
//
// Copyright (c) 2015 The Readium Foundation and contributors. All rights reserved.
//
// The Readium SDK is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>
//
#import <Foundation/Foundation.h>

@interface DrmInitialize : NSObject

- (void)initialize;

@end

Loading