ACSMDownloader

ACSMDownloader Commit Details

Date:2021-04-29 18:28:34 (2 months 28 days ago)
Author:Grégory Soutadé
Commit:0db25f5610f48ea6da847990053bc28f302338d0
Parents: 1f582f55f35b3a6898ced8d388e043ee81168bd1
Message:UI changes

Changes:
Minclude/rmsdk_wrapper.h (5 diffs)
Msrc/main.cpp (6 diffs)

File differences

include/rmsdk_wrapper.h
2727
2828
2929
30
31
30
31
32
3233
3334
3435
......
6364
6465
6566
66
67
67
68
6869
6970
7071
7172
7273
7374
74
75
7576
7677
7778
......
8182
8283
8384
84
85
8586
8687
87
88
89
90
91
92
93
94
95
96
97
8898
8999
90100
......
93103
94104
95105
96
106
97107
98108
99109
100110
101111
102112
103
113
114
115
116
117
118
104119
105120
106
121
107122
108123
109124
110
125
111126
112
127
113128
114129
115130
116
131
117132
118133
119134
......
128143
129144
130145
131
146
132147
133148
134149
class MockDRMProcessorClient: public dpdrm::DRMProcessorClient
{
public:
MockDRMProcessorClient(const char* output):
output(output), sourceName(0), targetName(0)
MockDRMProcessorClient(const char* outputDir, const char* outputFile):
outputDir(outputDir), outputFile(outputFile),
sourceName(0), targetName(0)
{}
virtual ~MockDRMProcessorClient() {
dp::String title = getMetadata(list[0], "title");
uft::String fullName;
if (output)
targetName = strdup(output);
if (outputFile)
targetName = strdup(outputFile);
else if (title.utf8())
{
uft::String fullName = title.uft() + ".epub";
targetName = fullName.utf8();
if (!targetName || !strlen(targetName))
targetName = (char*) "output.epub";
targetName = strdup("output.epub");
else
targetName = strdup(targetName);
}
targetName = fullName.utf8();
if (!targetName || !strlen(targetName))
targetName = (char*) "output.epub";
targetName = strdup("output.epub");
else
targetName = strdup(targetName);
}
}
dp::String author = getMetadata(list[0], "creator");
dp::String publisher = getMetadata(list[0], "publisher");
dp::String language = getMetadata(list[0], "language");
LOG(INFO, "Title : " << title.utf8());
LOG(INFO, "Author : " << author.utf8());
LOG(INFO, "Publisher : " << publisher.utf8());
LOG(INFO, "Language : " << language.utf8());
}
}
}
virtual void mockclientfn4(void) {LOG_FUNC();}
virtual void mockclientfn5(void) {LOG_FUNC();}
virtual void workflowProgress(unsigned int workflow, dp::String& title, double progress)
{
{
LOG(WARN, "Progress " << workflow << " " << title.utf8() << " " << progress << " %%");
if (workflow & WORKFLOW_DOWNLOAD)
{
if (progress == 100.0)
{
// Copy tmp file into destination
QFile file(targetName);
if (!outputDir)
outputDir = ".";
QString targetFileName = QString(outputDir) + QString("/") + QString(targetName);
QFile file(targetFileName);
if (file.exists())
{
LOG(DEBUG, "Removing existant target");
LOG(DEBUG, "Removing existant target " << outputDir << "/" << targetName);
file.remove();
}
if (QFile::rename(sourceName, targetName))
if (QFile::rename(sourceName, targetFileName))
{
LOG(INFO, "Created \"" << targetName << "\"");
LOG(INFO, "Created \"" << outputDir << "/" << targetName << "\"");
}
else
{
LOG(ERROR, "Unable to copy \"" << sourceName << "\" into \"" << targetName << "\"");
LOG(ERROR, "Unable to copy \"" << sourceName << "\" into \"" << outputDir << "/" << targetName << "\"");
}
}
}
private:
adept::DRMProcessorImpl* processor;
const char* output;
const char *outputDir, *outputFile;
char* sourceName;
char* targetName;
/*
src/main.cpp
1919
2020
2121
22
2223
2324
2425
......
4950
5051
5152
52
53
5354
5455
5556
......
115116
116117
117118
118
119
119120
120121
121122
122123
123
124
125
124126
125127
126128
......
145147
146148
147149
150
148151
149152
150153
......
152155
153156
154157
155
158
156159
157160
158161
......
170173
171174
172175
176
177
178
173179
174180
175181
static char* devicekeyFile = 0;
static char* acsmFile = 0;
static char* outputFile = 0;
static char* outputDir = 0;
class ACSMDownloader
{
LOG(DEBUG, "Create Adobe objects");
MockDRMProcessorClient processorClient(outputFile);
MockDRMProcessorClient processorClient(outputDir, outputFile);
MockDevice device(&processorClient, deviceFile, activationFile, devicekeyFile);
MockProvider provider(&device);
device.setProvider(&provider);
{
std::cout << "Download EPUB file from ACSM request file" << std::endl;
std::cout << "Usage: ./acsmdownloader [(-d|--device-file) device.xml] [(-a|--activation-file) activation.xml] [(-o|--output-file) output.epub] [(-v|--verbose)] [(-h|--help)] (-k|--device-key-file) devkey.bin (-f|--acsm-file) file.acsm" << std::endl << std::endl;
std::cout << "Usage: ./acsmdownloader [(-d|--device-file) device.xml] [(-a|--activation-file) activation.xml] [(-O|--output-dir) dir] [(-o|--output-file) output.epub] [(-v|--verbose)] [(-h|--help)] (-k|--device-key-file) devkey.bin (-f|--acsm-file) file.acsm" << std::endl << std::endl;
std::cout << " " << "-d|--device-file" << "\t" << "device.xml file from ereader" << std::endl;
std::cout << " " << "-a|--activation-file" << "\t" << "activation.xml file from ereader" << std::endl;
std::cout << " " << "-k|--device-key-file" << "\t" << "private device key file (eg devkey.bin) from ereader" << std::endl;
std::cout << " " << "-o|--output-file" << "\t" << "Optional output epub filename" << std::endl;
std::cout << " " << "-O|--output-dir" << "\t" << "Optional output directory were to put result (default ./)" << std::endl;
std::cout << " " << "-o|--output-file" << "\t" << "Optional output epub filename (default <title.epub>)" << std::endl;
std::cout << " " << "-f|--acsm-file" << "\t" << "ACSM request file for epub download" << std::endl;
std::cout << " " << "-v|--verbose" << "\t\t" << "Increase verbosity, can be set multiple times" << std::endl;
std::cout << " " << "-h|--help" << "\t\t" << "This help" << std::endl;
{"device-file", required_argument, 0, 'd' },
{"activation-file", required_argument, 0, 'a' },
{"device-key-file", required_argument, 0, 'k' },
{"output-dir", required_argument, 0, 'O' },
{"output-file", required_argument, 0, 'o' },
{"acsm-file", required_argument, 0, 'f' },
{"verbose", no_argument, 0, 'v' },
{0, 0, 0, 0 }
};
c = getopt_long(argc, argv, "d:a:k:o:f:vh",
c = getopt_long(argc, argv, "d:a:k:O:o:f:vh",
long_options, &option_index);
if (c == -1)
break;
case 'f':
acsmFile = optarg;
break;
case 'O':
outputDir = optarg;
break;
case 'o':
outputFile = optarg;
break;

Archive Download the corresponding diff file

Branches