Adapter for libpepmime, offering ObjC API.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

57 lines
1.5 KiB

//
// PEPMessage2MIMEUtil.m
// pEpMimeObjCAdapter_macOS
//
// Created by Andreas Buff on 01.07.21.
//
#import "PEPMessage2MIMEUtil.h"
#import <PEPObjCAdapterTypes_macOS/PEPObjCAdapterTypes_macOS.h>
#include <pEpMIME.hh>
#include <string>
#include <iostream>
#import "PEPMessage+Engine.h"
@implementation PEPMessage2MIMEUtil
//BUFF:
// check: 11:46 <Roker> die generierte MIME-Message ist 7-bit-ASCII sogar.
- (nullable NSData*)mimeDataFromPEPMessage:(PEPMessage *)pEpMessage error:(NSError **)error {
message *engineMsg = [pEpMessage toStruct];
if (engineMsg == nil) {
// set error
return nil;
}
/*
11:54 <Roker> also: wenn der bool 'true' ist, werden in der generierten Message ein paar interne header und flags gesetzt, mehr nicht.
11:56 <Roker> "if unsure say 'no'" :-D
*/
BOOL has_pEp_msg_attachment = false;
BOOL omit_fields = false;
char* c = pEpMIME::generate_message(engineMsg, omit_fields, has_pEp_msg_attachment);
if (c == NULL) {
// set error
return nil;
}
//BUFF: rm
std::cout << c << std::endl;
std::cout << "§§§§§§§§§§§§§§§§§§" << std::endl;
NSString *mimeString = [NSString stringWithUTF8String:c];
if (!mimeString) {
// set error
free(c);
return nil;
}
free(c);
NSData *mimeData = [mimeString dataUsingEncoding:NSUTF8StringEncoding];
if (!mimeData) {
// set error
return nil;
}
return mimeData;
}
@end